Mercurial > hg > aboriginal
view sources/toys/unique-port.sh @ 1187:878dbfe76341
Move $BUILD/logs creation from record-commands.sh to include.sh so it gets reliably recreated when a user blanks the logs and re-runs.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 01 Aug 2010 15:19:00 -0500 |
parents | 94b0b4ef1157 |
children | 1cdd44f2bac2 |
line wrap: on
line source
unique_port() { # Try to find an unused port number for each running instance of the program. START=8192 RANGE=$[$(awk '{print $1}' /proc/sys/net/ipv4/ip_local_port_range)-$START] if [ $RANGE -lt 1 ] then START=$[$(awk '{print $2}' /proc/sys/net/ipv4/ip_local_port_range)] RANGE=$[65535-$START] fi echo $[($$%$RANGE)+$START] }