proc unique_port { # Try to find an unused port number for each running instance of the program. global START := '8192' global RANGE := $($(awk '{print $1}' /proc/sys/net/ipv4/ip_local_port_range)-) if test $RANGE -lt 8 { global START := $($[awk '{print $2}' /proc/sys/net/ipv4/ip_local_port_range]) global RANGE := $(65535-) if test $RANGE -lt 8 { global START := '16384' global RANGE := '32768' } } echo $(($$%$RANGE)+) }