Skip to content

Instantly share code, notes, and snippets.

@scottsbaldwin
Created September 13, 2016 14:59
Show Gist options
  • Save scottsbaldwin/d71b76e4d369925477d0decdd8b28371 to your computer and use it in GitHub Desktop.
Save scottsbaldwin/d71b76e4d369925477d0decdd8b28371 to your computer and use it in GitHub Desktop.
Check if host:port is up
#!/bin/bash
# see https://securityreliks.wordpress.com/2010/08/20/devtcp-as-a-weapon/
echo "Waiting for ${HOST}:${PORT} to become available"
while :
do
(echo > /dev/tcp/${HOST}/${PORT}) >/dev/null 2>&1
available=$?
if [[ $available -eq 0 ]]; then
echo "Service on ${HOST}:${PORT}" is available
break
fi
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment