Re: pppd problem -- modem *not* disconnecting when connection lost.
On Thu, 1 Feb 1996, Craig Sanders wrote:
>
> On Tue, 30 Jan 1996, Kevin M Bealer wrote:
>
> > ping -c 1 www.sgi.com | grep "received" > $HOME/ooga
> > if [ ! -s $HOME/ooga ]
> > then
> > (command to kill pppd)
> > sleep 5
> > (command to restart pppd)
> > fi
>
> The trouble with that script is that ping's output will always contain
> the word "received". Here's an example (my annex is currently powered
> down - I don't need 16 text terminals here at home right now :-)
>
> $ ping -c 1 annex
> PING annex.taz.net.au (203.16.167.2): 56 data bytes
>
> --- annex.taz.net.au ping statistics ---
> 1 packets transmitted, 0 packets received, 100% packet loss
> ^^^^^^^^^^^^^^^^^^
>
> It's much better to check the interface using ifconfig...
>
> So, ping isn't a particularly good method of testing whether your PPP link
> is up.
>
>
> Here's what I run from cron every 5 minutes. Note that it won't detect
> a stuck pppd process (as has already been posted, the lcp-echo* options
> are good for that), but is a good general solution for testing whether
> the ppp interface is up or not.
>
> ---cut here
> #!/bin/sh
>
> REMOTE_IP=192.88.6.9
>
> # if link is up, exit immediately.
> /sbin/ifconfig | /usr/bin/grep $REMOTE_IP >/dev/null 2>&1 && exit 0
>
> DEVICE=cua3
> SPEED=57600
>
> /usr/sbin/pppd /dev/$DEVICE $SPEED
> ---cut here---
>
> The output of ifconfig is piped into grep. If the ppp link is up, then
> there will be an interface which looks like this:
>
> ppp0 Link encap:Point-Point Protocol
> inet addr:192.88.6.42 P-t-P:192.88.6.9 Mask:255.255.255.0
> UP POINTOPOINT RUNNING MTU:1500 Metric:1
> RX packets:20185 errors:3 dropped:3 overruns:0
> TX packets:23042 errors:0 dropped:0 overruns:0
>
> and grep will find "192.88.6.9" and exit with an exit code of 0
> (success), which causes the script to exit immediately ("&& exit 0").
>
> If grep doesn't find "192.88.6.9" then it will exit with a non-zero exit
> code (failure), and execution of the script will continue at the following
> line.
>
> This works.
>
> Note that this script can be called from cron or run at the command
> line. If the link's alreay up, then nothing happens. if it's down then
> it's started up.
>
>
> Craig
>
> --
> cas@muffin.pronet.com cas@muffin.apana.org.au
> * Unix Consulting: Installation, Configuration, & Support. *
> * --- Also, contact me if you need your Dos/Win/OS2 LAN connected to --- *
> * --- the Internet. --- *
>
>
>
_____Running_Debian_Linux__(stable)__version_1.2.13___________
This is a test of the emergency broadcasting system. In the / --beeeeep--
case of a real emergency, this message would be followed by / Kevin Bealer
light relaxing music, and I would be on my way to Idaho, / kmb203@psu.edu
where cousin Jake has a concrete bunker with a six year \______
supply of shotgun shells and ... um, gotta go! ... (light music) |
__________________________________________________________________|
Reply to: