moth/octopus/solution.sh

15 lines
342 B
Bash
Raw Normal View History

2010-09-26 21:56:51 -06:00
#! /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