btw, if I need to check if the network is up in a script, I usually do

ping -q -c1 -w4 some.remote.host >/dev/null 2>&1 && command-to-run-if-remote-host-reachable

It the advantage that it checks directly connection to the host
you wish to connect to, so it also won't run the command if your network
is up, but the remote host is inaccessible...

If your server doesn't respond to pings, just use some other server
(eg google's public dns 8.8.8.8)


Or you could use hping, which has the advantage that it tests the actual service you want to use, rather than just the host it sits on;

sphinx adam # hping2 -c 1 -S -p 80 www.google.com >/dev/null 2>&1 && echo "it worked"
it worked