LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
[stats]
From: Jake Hawkes <jake@infinitylimited.net>
To : Michael Kratz <michael_kratz@hotmail.com>
LinuxSA Mailing List <linuxsa@linuxsa.org.au>
Date: Tue, 27 Feb 2001 03:15:32 +0000
Re: pppd reconnect script
Michael Kratz wrote:
>
> Hi Jake, thanks for your input, I am trying hard to understand this script
> but it is kinda a little over my head, how does it work??
Michael, I took the liberty of cc'ing the list. Maybe someone else will
gain something.
> so where would i add the bit like 'pppd call provider' I dont use the ppp0up
> thing i dont understand that either!!!! pretty dumb eh! I ve only been
> messing with linux since the installfest.
>
> >so...
> >
> >#!/bin/bash
> >ping -c1 1.1.1.1
here, 1.1.1.1 is the ip of your ppp peer. when you do a ifconfig, you
will see a lines like this:
ppp0 Link encap:Point-to-Point Protocol
inet addr:166.72.64.158 P-t-P:166.72.52.11
Mask:255.255.255.255
so, I would replace 1.1.1.1 with 166.72.52.11
whenever you run a command, it will return a status. This way, scripts
can tell if the program had an error or not. This is always stored in
the assumed variable $? in bash.
(An assumed variable is one that you do not define, and is usually set
by something other than your code)
> >
> >STATUS=$?
I store the value of the variable here for readability.
> >
> >echo "$STATUS returned"
a debug message
> >
> >case $STATUS in
a case (or switch) statement. This allows me to test the value of the
variable against many values, unlike an "if" statement, which only tests
the value against one value[1].
> > 0)
> > echo "next host in route alive"
> > ;;
here, I say "if the value of status is 0, the print this line, and then
jump to the end of the case statement.
> > 1)
> > echo "no packets returned"
> > ;;
here, I say "if the value of status is 1, the print this line, and then
jump to the end of the case statement.
> > 2)
> > echo "there was an error"
> > ;;
same
> > *)
> > echo "I dunno"
here I say, if I have not had any matches yet, then print this line
> >esac
this is the end of the case statement. When I say "jump to the end of
the case statement", here is where it jumps to.
you can put any number of commands in the case statements. so, you would
put:
1)
echo "link dead, initiating redial";
killall pppd
pppd call provider
;;
be aware that the ;; is important. it signifies the end of that block of
code, it is particular to case() statements in bash scripts.
I reckon that you might be using debian, or at least something without
"ifup" which I think is redhat (and so Mandrake to I think).
any debian-ers out there know the best way to initiate a redial? I
haven't looked to see if it is pppd that does the redial of the ifup
script.
--
Jake Hawkes B.Eng, (CSE)
Sleep is good. It'll keep you from going psychotic.
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
[stats]
Return to the LinuxSA Mailing List Information Page