Last active
January 2, 2016 07:29
-
-
Save coderofsalvation/8270458 to your computer and use it in GitHub Desktop.
bash function to check if internet is available
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
has_internet() | |
{ #check for internet connection, returns 0 on success, 1 otherwise | |
wget --tries=3 --timeout=5 http://www.google.com -O /tmp/index.google > /dev/null 2>&1 | |
if [ -s /tmp/index.google ]; then | |
rm /tmp/index.google | |
return 0 | |
else | |
rm /tmp/index.google | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment