Skip to content

Instantly share code, notes, and snippets.

@davidaparicio
Created May 25, 2012 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidaparicio/2790671 to your computer and use it in GitHub Desktop.
Save davidaparicio/2790671 to your computer and use it in GitHub Desktop.
A bash script to try if you have internet connection
#!/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