Created
September 22, 2012 00:43
-
-
Save ataliba/3764693 to your computer and use it in GitHub Desktop.
Checking Internet Connection with wget
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
#!/bin/bash | |
HOST=$1 | |
WGET="/usr/bin/wget" | |
$WGET -q --tries=10 --timeout=5 $HOST | |
RESULT=$? | |
if [[ $RESULT -eq 0 ]]; then | |
echo "Connection made successfully to $HOST" | |
else | |
echo "Fail to make connection to $HOST" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original code: http://linuxpoison.blogspot.com.br/2012/09/bash-script-script-to-check-internet.html#ixzz279e7i9CI