Created
June 20, 2014 19:28
-
-
Save mariuswilms/56fd63b6a251254ba311 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Continuously checks online/offline status and notifies | |
# you when the status changes. Works only where the "say" | |
# command is available. | |
# | |
# Dedicated to the public domain. | |
# | |
last= | |
while true; do | |
ping -o -t 2 www.google.de &>/dev/null | |
cur=$? | |
if [[ $cur != 0 ]]; then | |
echo -n "0" | |
else | |
echo -n "1" | |
fi | |
if [[ $cur != $last ]]; then | |
if [[ $cur != 0 ]]; then | |
say "offline" | |
else | |
say "online" | |
fi | |
last=$cur | |
fi | |
sleep 2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment