Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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
share|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

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"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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