From owner-freebsd-hackers Thu Mar 5 07:07:56 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA24914 for freebsd-hackers-outgoing; Thu, 5 Mar 1998 07:07:56 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from spiv.fnal.gov (spiv.fnal.gov [131.225.124.126]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA24890 for ; Thu, 5 Mar 1998 07:07:53 -0800 (PST) (envelope-from neswold@fnal.gov) Received: from localhost (neswold@localhost) by spiv.fnal.gov (8.8.5/8.8.5) with SMTP id JAA05013; Thu, 5 Mar 1998 09:09:14 -0600 (CST) X-Authentication-Warning: spiv.fnal.gov: neswold owned process doing -bs Date: Thu, 5 Mar 1998 09:09:14 -0600 (CST) From: "Richard M. Neswold" Reply-To: neswold@fnal.gov To: Peter van Heusden cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Detecting state of PPP In-Reply-To: Message-ID: X-Spambot-Food: abuse@localhost postmaster@localhost abuse@fbi.gov MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 5 Mar 1998, Peter van Heusden wrote: > How does one go about writing a program to check if a PPP link is up or > down? I'm running PPP in -auto mode, and I'd like to be able to tell > whether the PPP link is actually up (i.e. the modem connection is in > place) at any particular time. Unfortunately, the flags on tun0 stay the > same (0x8051 on my system) whether the modem is connected or not. What > should I be looking at? If you're looking for a way to do it in a script, I've found two successful methods. Both methods use 'ifconfig' to check the state. The first method is in Perl. The following test works on my system: if (index(`ifconfig -l -u`, "tun0") > -1) { ... this code executes when 'tun0' is active... } I use a different method in my crontab file. My cron job to periodically grab the latest sources has this command (I took out the full paths to make it fit on one line): ifconfig -l -u | grep -q tun0 && cvsup -L 1 -g /etc/supfile This way, I only grab the sources if my connection is active. You can test for "down" interfaces by replacing the -u option with -d. Hope this helps... Rich ------------------------------------------------------------------------ Richard Neswold, Accelerator Div./Controls Dept | neswold@fnal.gov Fermilab, PO Box 500, MS 347, Batavia, IL 60510 | voice (630) 840-3454 'finger neswold@aduxb.fnal.gov' for PGP key | fax (630) 840-3093 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message