Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Is Comcast up?" shell script
#!/bin/sh
# Original version developed by Reverend Booyah! (SteveCook.net)
# First, ping Comcast's web server
ping -q -c 2 www.comcast.net &> /dev/null
if [ $? -ne 0 ] ; then
echo "Comcast didn't work"
# If Comcast fails, that's Strike 1. Next, ping Yahoo's web server
ping -q -c 2 yahoo.com &> /dev/null
if [ $? -ne 0 ] ; then
echo "Yahoo didn't work"
# If Yahoo fails, that's Strike 2. Next, ping Google's web server
ping -q -c 2 google.com &> /dev/null
if [ $? -ne 0 ] ; then
echo "Google didn't work"
# Since Google also failed, that's Strike 3. Time to power cycle the modem and router!
echo "Initiating reboot script"
# Send yourself an email with the script output
/usr/bin/smtp-cli --missing-modules-ok --ipv4 --server=localhost --host=mail.example.com --port=587 --enable-auth --user username --pass password --from root@example.com --to yourself@example.com --subject "Reboot Alert"
# Pipe the reboot script through telnet
/usr/local/bin/reboot_script.php | telnet
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.