Created
October 19, 2017 19:35
-
-
Save deckerego/be3463d84e7fba10ac3c8cb67b6cc2c7 to your computer and use it in GitHub Desktop.
Sleep while waiting for a TCP port to open, then execute a command
This file contains hidden or 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
#!/bin/bash | |
HOST="$1" | |
PORT="$2" | |
RUNNING=1 | |
while [[ $RUNNING -ne 0 ]]; do | |
echo "Waiting for $HOST:$PORT..." | |
sleep 3 | |
nc -z "$HOST" "$PORT" | |
RUNNING=$? | |
done | |
${@:3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment