----- Original Message -----
From: Richard Adams <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 30, 1999 9:18 AM
Subject: Re: Shell script pinging for HR6.1
> 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.
Oh so I cann't write #!/bin/sh scripts on the fly. Doh, close enough to know
what it means any way. I guess I should run it though, next time, real
quick so I don't look like a dumbass, a?
while [ 1 ]
do
ping -c1 isp.domain.com > /dev/null 2> /dev/null
done
happy?
Most of the errors you get from this, is if, you are not connected up.
Since we probably know that we are not connected up, we don't need the error
messages.
Anyways, like I said it was a quick script. Only had 15 minutes to get
though /all/ of my email this morning.
Jack
>
> 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
>
>