🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.linux
Article #54243

Re: How do I keep PPP alive

#54243
From: BaRT
Date: Thu, 20 Nov 1997 00:00
115 lines
3849 bytes
This is a multi-part message in MIME format.
--------------3A23457541D52A39427E82FC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

Here is a small perl script to dail and redial if ppp connection is lost.

BaRT

Health Communication Network wrote:

> Hi all,
>
> I have a linux machine that serves a room full of pcs for net access.
>
> I would like to know how to keep the PPP connection alive. The machine
> now may be a 24 hour link but the modem drops carrier from time to time.
>
> Is it possible to get it to redail and connect ppp again when it dies?
>
> It is Redhat linux
>
> Thanks



--
         \\|//
         (. .)
+----oOOo-(_)-oOOo----+
|    Linux Rules!!    |
+---------------------+
bart@aceonline.com.au



--------------3A23457541D52A39427E82FC
Content-Type: application/x-perl; name="pppwatch.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="pppwatch.pl"

#!/usr/local/bin/perl
# PPP Watch/Redialer
# 10/22/97
# bwilson@wfu.edu
#
# Will redial if busy and will redial if ppp connection is lost
# Quick and dirty, but gets the job done.
# 
# NOTE: THIS IS NOT DESIGNED TO KEEP YOUR CONNECTION UP.
#       IF YOU WANT TO KEEP YOUR CONNECTION UP, USE SOMETHING
#	LIKE 'fetchpop' TO CHECK FOR MAIL EVERY SO OFTEN.
#	OR HACK MY CODE AND ADD A 'ping' STATEMENT OR SOMETHING.
#
# chmod 4755 pppwatch - if you want to allow other users to run ppp
# chmod +x pppwatch - if not ;)
#
# I run this from a menu driven front end that lets
# me select from different ISP's, but it will work fine
# the way it is.  Let me know if you update it.
#
####################################################################
################## EDIT FIELDS BELOW ###############################
####################################################################

$pppon="/usr/sbin/ppp-on"; # the location of your ppp on script
			   # make sure that your script doesn't
			   # redial automaticly, as it and 
			   # pppwatch will fight over who
			   # gets to connect.
$prog="/usr/bin/pppupdate"; # program to run after successful
			    # connection.  I run my ml.org
			    # script to update my dynamic address

##################################################################
################## DO NOT EDIT BELOW HERE ########################
##################################################################
$ENV{PATH}="/usr/bin/";
($(, $)) = (0,0); # sets to group to 0 (root)
($>, $<) = (0,0); # sets to user to 0 (root)

for (;;) {  #infinate loop - daemon like 
	@info=`/sbin/ifconfig`;
	if(grep(/ppp/,@info)) {
		# ppp is found in ifconfig, thus ppp is up	
	} else {
		# ppp is down
		# redial the isp
		print STDOUT "PPP is Down\n";
		print STDOUT "Redialing ISP\n";
		# run your ppp up scripts here
                system("$pppon");
		system("/bin/sleep 40");
		# after 40 seconds, check to see if the connection
		# was successful.
		# if so, run $prog
		@info=`/sbin/ifconfig`;
        	if(grep(/ppp/,@info)) {
			system("$prog");
		} else {
			# connection failed - busy 
			# redial if connection failed
			redo;
		}
	}
	# if the system is connected, sleep for 200 seconds.
	# then check to see if its still connected
system("/bin/sleep 200");
}


--------------3A23457541D52A39427E82FC--
Technical Details
Message-ID: <34731A69.AE993351@nospam.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3470E166.54FACE1F@hcn.net.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 102983,12c69a36b12dea3
X-Google-Attributes: gid102983,public
From: BaRT <bart@nospam.com>
Subject: Re: How do I keep PPP alive
Date: 1997/11/20
Message-ID: <34731A69.AE993351@nospam.com>
X-Deja-AN: 291037722
References: <3470E166.54FACE1F@hcn.net.au>
To: Health Communication Network <peter.shilling@hcn.net.au>
Organization: Western Australia Internet Association
Newsgroups: aus.computers.linux