Created
January 28, 2012 03:29
-
-
Save anonymous/1692424 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check_port () | |
{ | |
netstat -tpln 2> /dev/null | sed -E '/^[^t]/ d; s/^([^ ]+ +){3}//; s/ .*$//; s/^.*://;' | grep --color "^$1$" > /dev/null | |
} | |
wait_port () | |
{ | |
typeset t; | |
t=$2; | |
while (( $t > 0 )) && ! check_port $1; do | |
echo "waiting for port $1 for $t secconds."; | |
sleep 1s; | |
(( t-- )); | |
done; | |
check_port $1 && echo "Port $1 started." || { | |
echo "Port $1 was not started"; | |
false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment