Bring over octopus solution

This commit is contained in:
Neale Pickett 2010-09-26 21:56:51 -06:00
parent 48caa26556
commit d6f6d27b0f
1 changed files with 15 additions and 0 deletions

15
octopus/solution.sh Executable file
View File

@ -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