[NBLUG/talk] shell scripting help
seanvanco at gmail.com
Tue Jun 10 13:46:12 PDT 2008
I'm trying to set up a basic ping test, as my internet connection
appears to have trouble in the early morning. I need to prove that it
is occurring and track when it happens.
It's been a long time since I've done any scripting, especially with
loops, so I was hoping someone could help me. I can't get the looping
to work in the below code, which I've patched together using samples
from various websites. Could anyone tell me what I need to do? My
intent is to have cron run this and have the script terminate once the
number of loops has been reached.
while [ loops != 180 ]
if [ -z "$1" ]; then
echo "Usage: `basename $0` ip-addr"
ping -c 1 -W 10 $1 &>/dev/null
if [ $? -eq 0 ];
#then / echo "Ping succeeded"
# Commands here
echo "Ping failed" >> /var/log/ping_test.log
date >> /var/log/ping_test.log
loops=`expr $loops + 1`
More information about the talk