diff --git a/octopus/solution.sh b/octopus/solution.sh new file mode 100755 index 0000000..3745ab0 --- /dev/null +++ b/octopus/solution.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +port=8888 + +blooper=$(tempfile) +trap "rm $blooper" 0 + +echo foo | socat -t 0.01 STDIO UDP:127.0.0.1:8888 | tail -n +4 > $blooper + +for i in $(seq 8); do + result=$(socat -t 0.01 STDIO UDP:127.0.0.1:$port < $blooper | awk -F': ' '(NF > 1) {print $2; exit;}') + port=$(echo "ibase=8; $result" | bc) + echo $port +done +echo $result \ No newline at end of file