On Thu, 30 Dec 1999,  Jack Barnett wrote about,  Re: Shell script pinging for HR6.1:
> A quick script would be
> 
> #!/bin/sh
> 
> while (1)
> do
>  ping ping -c1 isp.domain.com > /dev/null 2> /dev/null
>  sleep 240
> done;
> 
> It will ping you ISP every 4 minutes.  If you want to kill it, use a ^C
> 
> You should check to make sure you have the your ppp connect up before trying
> to ping anything, and then modify anything that is Red Hat specif.

That is not so handy when one terminal is tyed up like that, simply start
the script with;

./scriptname &
To kill it kill its PID number, the sleep pid will die itself.

The reason the origanal script gives an error is the two &&'s and the
redirect to /dev/null. The script does not work like it used to either,
things have changed, ping returns 0% packet loss not 0 packets, so there
will be nothing zero.

Jack's script will not work either, several reasons.

1) Its while :
    not while (1)
2) Its ping 
    not ping ping
3) >/dev/null
   should be enough.

There is no real need to have the semi colon either at the end of "done"
altho, its debatable.

The origanal should at lease send pings, i cant check the rest, i have no
ppp here.

if [ -f /var/run/ppp0.pid ]; then
        ping -c5 -l3 IP# >&1| grep "0% packet"  \
        { /usr/sbin/ppp-off > /dev/null 2>&1 ; sleep 2 ; /usr/sbin/ppp-go } 
else
       /usr/sbin/ppp-go
fi                        

At least i dont get any syntax errors with the above and it returns the
result of the grep ok.

> Jack
> 
> ----- Original Message -----

> > > > /sbin/keepalive.sh: line 8: syntax error near unexpected token
`else' > > > > /sbin/keepalive.sh: line 8: `else'
> > >
> > > Here is the shell script pasted from an xterm...
> > >
> > > #!/bin/sh
> > > #
> > > # Script to keep the ppp0 port up by pinging and then grepping results
> > > #
> > > if [ -f /var/run/ppp0.pid ] ; then
> > >  ping -c5 -l3 204.249.184.2 2>&1 | grep "0 packets" > /dev/null && \
> > >  { /usr/sbin/ppp-off > /dev/null 2>&1 ; sleep 2 ; /usr/sbin/ppp-go }
> > > else
> > >  /usr/sbin/ppp-go
> > > fi
> > > # Done
> > >

-- 
Regards Richard
[EMAIL PROTECTED]
http://people.zeelandnet.nl/pa3gcu/
Happy New Year

Reply via email to