Date: Thu, 5 Mar 1998 09:09:14 -0600 (CST) From: "Richard M. Neswold" <neswold@fnal.gov> To: Peter van Heusden <pvh@leftside.wcape.school.za> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Detecting state of PPP Message-ID: <Pine.BSF.3.96.980305090154.4978B-100000@spiv.fnal.gov> In-Reply-To: <Pine.BSF.3.95.980305071307.15655F-100000@leftside.wcape.school.za>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980305090154.4978B-100000>