[99889] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: Check for ppp connexion in script

daemon@ATHENA.MIT.EDU (bsc@klondike.ml.org)
Tue Nov 17 12:59:48 1998

From: bsc@klondike.ml.org
Date: Tue, 17 Nov 1998 09:58:38 -0800
To: redhat-list@redhat.com
In-Reply-To: <Pine.LNX.4.05.9811170052210.6342-100000@winbuster.magic.fr>; from Zoki on Tue, Nov 17, 1998 at 01:05:35AM +0100
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

Depending on how you make the PPP connection when you want to go online
interactively, you could have all scripts create a temporary lock file
somewhere (/var/lock comes to mind). All scripts could then check for
this lock file before attempting to connect. Just remember to have
scripts remove the lock file when they're done.

You could also attempt something like:

	#!/bin/bash

	if [ "`ps ax | grep ppp | grep -v grep`" = "" ]
	then
		echo "ppp is not running"
	else
		echo "ppp is running"
	fi

I'm sure there are simpler, more elegant solutions. This is a two minute
quickie. One caveat: I don't have PPP running on the machine I'm
currently using so I'm at a loss as to what string you should be
searching the output from `ps` for. You would have to customize the 
initial grep so it would only find the PPP connection process, not some 
other unrelated process.

Finally, if you are uncomfortable with grep you could look at the man
page. Granted, it's not the friendliest place to get the information you
need. Another wonderful resource for learning enough grep to be dangerous
(as well as awk, xargs, find, and a goodly sum on script writing) is 
"Essential System Administration" by Aileen Frisch, it's published by
O'Reilly.

Regards,
Blair.
	
On Tue, Nov 17, 1998 at 01:05:35AM +0100, Zoki wrote:
> Since I've scripts as cronjobs to take care of mail I 'm having the
> annoying experience that the scripts try to make a connection even if I'm
> allready on line. What I would like to do is make the script check if
> there is a connection and if so skip the dialing and go straight to
> downloading and sending mail. I checked in the archives but couldn't find
> the answer to this question. I've an idea I should work with grep but
> since I never used it, I don't know its "grammar".
> 
> Thanks,
> Zoki.
> _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
> ZOKImage Paris
> 	Creation d'images est traitement numerique
> 			Image creation & digital tweaking
> _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
> 
> Mailed with Linux and Pine.
> 
> 
> 
> -- 
>   PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
> 		http://www.redhat.com http://archive.redhat.com
>          To unsubscribe: mail redhat-list-request@redhat.com with 
>                        "unsubscribe" as the Subject.

-- 
--- end ---
Blair Craft
bsc@klondike.ml.org
http://www.klondike.ml.org/~bsc
          


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post