Created
May 25, 2012 21:21
-
-
Save davidaparicio/2790671 to your computer and use it in GitHub Desktop.
A bash script to try if you have internet connection
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
#!/bin/bash | |
SEC=0 # in seconds | |
MIN=0 # in minutes | |
while !(ping -c1 google.com > /dev/null 2>&1); do | |
echo $SEC | |
let SEC=SEC+1 | |
sleep 1 | |
done | |
let MIN=SEC/60 | |
let SEC=SEC-MIN*60 | |
echo the connection is returned after $MIN minutes and $SEC seconds | |
while true; do | |
espeak "" 2>/dev/null | |
if [ $? == 0 ]; #try if espeak is installed | |
then | |
espeak "It's work" 2>/dev/null | |
sleep 1 | |
else | |
exit 0; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment