PDA

View Full Version : Need help with script to detect network connection status


LemonFizz
06-27-2005, 12:14 AM
Hi,
I am trying to get my wife to use Skype. evrything goes well, but when she is not connectd to the web and starts her machine, Skype essentially locks the machine up looking for a network connection so my wife has taken Skype out of her startup items and now desn't use it that much. What I would like to be able to do is write either an applescript or a shell script that I could put in the startup items (or login items) that would look to see if a network connection was active (either ethernet or airport) and if so would start Skype (hidden if possible). If not then (obviously) it wouldn't start it.
Can anyone help. I have bought two rather good books on applescript and one on UNIX scripting and still can't find how to get the network connection status...any offers?
Cheers,
Lemon

toppledwagon
06-27-2005, 01:45 AM
I don't know how Apple's internal networking does this, but here is one way:

#!/bin/sh
/sbin/ping -c 1 `head -1 /etc/resolv.conf | awk '{ print $2 }'` > /dev/null
if [ $? -eq 0 ]; then
echo "I can reach my first name server."
else
echo "I can not reach my first name server."
fi

-Dave