Last active
June 22, 2016 19:14
-
-
Save bjorand/be911199dff69e14577fa3a97cba505d to your computer and use it in GitHub Desktop.
Wait for a TCP port, Bash style
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
wait_tcp_port() { | |
local host="$1" port="$2" | |
# see http://tldp.org/LDP/abs/html/devref1.html for description of this syntax. | |
while ! exec 6<>/dev/tcp/$host/$port; do | |
echo "$(date) - still trying to connect to $host:$port" | |
sleep 1 | |
done | |
exec 6>&- | |
} | |
wait_tcp_port <hostname> <port> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment