On 30 Dec, Richard Adams wrote:
> 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.
Hello Richard (and other newbies and gurus). I'm not very familiar with
shell scripts (my understatement of the year). I don't know why the
original I pulled from the Dynamic-IP-Hacks HOWTO has the redirection
to /dev/null (I assume because I don't want the result on my terminal)
and I have no idea why it has two && at the end.
My modified script now reads...
#!/bin/sh
#
# Script to keep the ppp0 port up
#
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
>From what I understand, this says "If I find ppp0 in use, then ping
this address 5 times and look for the string "0 packets" (which
indicates my connection has been lost). If it matches "0 packets" then
shut down my ppp connection, wait 2 seconds and fire up the ppp
connection again. Else (if no ppp0 pid is found) just fire up ppp to
begin with. If I grep for "0%", wouldn't that mean I have NO packet
loss in which case I don't want the other stuff to happen?
Also, my error was coming from the original script missing the
semi-colon after the "/usr/sbin/ppp-go" between the braces. When I
added that third semi-colon, the errors quit. I'm still not sure the
script is working correctly but at least I don't have a new mail in
root's mailfile every 5 mins :)
For the fellow that wanted to use a similar script under RH, I don't
see why the above wouldn't work if you just substitute whatever you run
for a ppp connection for the ppp-go above and whatever you run to shut
down ppp for the ppp-off above. (I don't know anything about how Red
Hat does it's ppp connection).
--
Scott Felton WF3R
[EMAIL PROTECTED]
http://www.k3ir.ampr.org
Slackware Linux