Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 4 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
4  
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .