Skip to content

Instantly share code, notes, and snippets.

@phips
Created April 23, 2014 22:19
Show Gist options
  • Save phips/11234471 to your computer and use it in GitHub Desktop.
Save phips/11234471 to your computer and use it in GitHub Desktop.
Quick Python one-liner connectivity check
SERVER=10.1.1.1
python -c "import socket; socket.create_connection((\"${SERVER}\",80),3)" 2>/dev/null
ret=$?
if [ $ret -eq 0 ]; then
# do stuff
else
# don't do stuff coz connectivity check failed
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment