Is there a way I can make a Mac Mini sound an audible alarm when it's not connected to the Internet?

I'm quite handy with bash, so if bash is the answer I could create a couple of commands - one to turn it on, one to turn it off - and create some desktop icons for it.

link|improve this question

44% accept rate
feedback

2 Answers

up vote 1 down vote accepted

The following loop will send a single ICMP ECHO request (ping) to your ISP and then sleep for a second. If a reply isn't received within two seconds, it will play the file alarm.wav.

YOUR_ISP=1.2.3.4
while :
do
  ping  -t 2 -o -c 1 $YOUR_ISP || open alarm.wav
  sleep 1
done
link|improve this answer
2  
for more fun, replace "open alarm.wav" with "say ping failed" – Doug Harris Sep 8 '09 at 19:42
will the test continue to run each second? will alarm.wav keep playing? will it re-open the wav every second? will it stop playing once connection has returned? – Phillip Oldham Sep 9 '09 at 8:14
The test will continue. The alarm will play continuously as long as the connection is down and will stop once the connection has returned. – Diomidis Spinellis Sep 19 '09 at 5:35
feedback

The following will ping once and tell iTunes to start playing if the ping failed.

ping -c 1 128.111.1.1 ||
osascript -e 'tell application "iTunes"' -e "play" -e "end tell"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.