Skip to content

Instantly share code, notes, and snippets.

@yanbe
Created May 12, 2011 02:25
Show Gist options
  • Save yanbe/967820 to your computer and use it in GitHub Desktop.
Save yanbe/967820 to your computer and use it in GitHub Desktop.
インターネットへの到達性を定期的に監視して、状態が変わるとしゃべる
#!/bin/sh
while true
do
ping -t 6 -i 2 www.google.com 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
echo "Network Has Gone"
if [ `cat ~/.netcheck.last` = "OK" ]
then
say "Network Has Gone"
fi
echo "Error" > ~/.netcheck.last
sleep 6
else
echo "Network Has Come"
if [ `cat ~/.netcheck.last` = "Error" ]
then
say "Network Has Come"
fi
echo "OK" > ~/.netcheck.last
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment