Skip to content

Instantly share code, notes, and snippets.

@Gordin
Created May 23, 2018 15:48
Show Gist options
  • Save Gordin/f1987995fe344f1c345d3b63d8fe944e to your computer and use it in GitHub Desktop.
Save Gordin/f1987995fe344f1c345d3b63d8fe944e to your computer and use it in GitHub Desktop.
#!/bin/sh
wait_for_hosts () {
for host in $@; do
while ! timeout 5 bash -c "echo > /dev/tcp/${host//:/\/}"; do
echo "$host is not available. Retrying..."
sleep 2
done
echo $host is available!
done
}
WAIT_FOR_HOSTS="google.com:80 google.de:80 bing.com:443"
wait_for_hosts $WAIT_FOR_HOSTS
wait_for_hosts google.com:80 google.de:80 bing.com:443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment