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 08:46:28AM
Hi, i am the anonymous author of this script. Here an enhanced version:

#!/bin/sh

HOST=www.freenet.de

# first initiate the values
if /sbin/ping -s1 -t4 -o $HOST &> /dev/null
then
NET=true
NETOLD=true
say "the internet connection is available."
else
NET=false
NETOLD=false
say "no internet connection."
fi

# endless loop
while true
do
if /usr/bin/sudo /sbin/ping -i0.1 -s0 -t2 -o $HOST &> /dev/null
then
NET=true;
LOST_NET_COUNT=0;
else
if [ $LOST_NET_COUNT == 1 ]
then
NET=false;
else
let "LOST_NET_COUNT += 1";
fi
fi
#echo NEW:$NET OLD:$NETOLD LOSTCOUN:$LOST_NET_COUNT
if [ $NET != $NETOLD ]
then
if [ $NET = true ]
then
say "the internet connection is available again." &
else
say "lost the internet connection." &
fi
fi
NETOLD=$NET
sleep 2
done
Please change the $HOST variable to the server of you choice...

[ Reply to This | # ]