mirror of
https://github.com/dirtbags/moth.git
synced 2025-01-06 03:50:56 -07:00
16 lines
374 B
Bash
Executable file
16 lines
374 B
Bash
Executable file
#! /bin/sh
|
|
|
|
port=8888
|
|
host=[${1:-::1}]
|
|
|
|
blooper=/tmp/bloop.$$
|
|
trap "rm $blooper" 0
|
|
|
|
echo foo | socat -t 0.01 STDIO UDP6:$host:$port | tail -n +5 > $blooper
|
|
|
|
for i in $(seq 8); do
|
|
result=$(socat -t 0.01 STDIO UDP6:$host:$port < $blooper | awk -F': ' '(NF > 1) {print $2; exit;}')
|
|
port=$(printf "%d" "0$result")
|
|
echo "next port: $port ($result)"
|
|
done
|
|
echo $result
|