Skip to content

Instantly share code, notes, and snippets.

@sochoa
Created July 6, 2012 04:55
Show Gist options
  • Save sochoa/3058194 to your computer and use it in GitHub Desktop.
Save sochoa/3058194 to your computer and use it in GitHub Desktop.
Pinging a Google DNS server to confirm internet connectivity
#!/bin/bash
host=8.8.8.8
while :
do
echo "Pinging $host"
ping_result=$(ping $host -c 1 -n -q | egrep "[0-9]+% packet loss" -o | sed 's/% packet loss//g')
if [[ ! $ping_result ]]; then
clear
date
echo -en "\n\n$host could not be reached"
else
echo -en "\n\n$host is UP! Hurray!!"
fi
sleep 10
clear
done
@sochoa
Copy link
Author

sochoa commented Jul 6, 2012

Things are good

Pinging 8.8.8.8


8.8.8.8 is UP!  Hurray!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment