Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A bash script to speak network status' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A bash script to speak network status
Authored by: ChristophLauer on Feb 05, '06 09:11:42AM
Hi again, here an script that starts the above script named "lookForNetwork.sh" on my machine if it is'nt running always. I start this script whith my cron minutely. Start crontab -e and add the following line */1 * * * * /Users/christoph/bin/AutoRunLookForNetwork.sh but dont forget to change the path... Here is the script.

#!/bin/sh
export PROCS=`/usr/bin/sudo -u christoph /bin/ps -axo command > /tmp/ps.out ; /usr/bin/grep lookForNetwork /tmp/ps.out | /usr/bin/wc -l`

#echo $PROCS

if [ $PROCS == 0 ]
then
# echo "lookForNetwork.sh dont run. Starting now..."
/usr/bin/sudo -u christoph /Users/christoph/bin/lookForNetwork.command &
#else
# echo "lookForNetwork-sh runns always..."
fi

exit 0;


[ Reply to This | # ]
A bash script to speak network status
Authored by: cbt on Feb 06, '06 12:24:42PM

Hello,

You can also check your route table for a default route:
if (netstat -rn | grep -q ^default) ; then
  echo "Default route exists (we're online)."
else
  echo "Default route doesn't exists (we're NOT online)."
fi

The route deamon should update the routing table when the connection is lost.

--
Cole



[ Reply to This | # ]