Created
April 23, 2014 22:19
-
-
Save phips/11234471 to your computer and use it in GitHub Desktop.
Quick Python one-liner connectivity check
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
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