From owner-freebsd-questions Fri Dec 26 20:02:42 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id UAA28809 for questions-outgoing; Fri, 26 Dec 1997 20:02:42 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id UAA28713 for ; Fri, 26 Dec 1997 20:02:15 -0800 (PST) (envelope-from brian@awfulhak.org) Received: from gate.lan.awfulhak.org (localhost [127.0.0.1]) by awfulhak.demon.co.uk (8.8.7/8.8.7) with ESMTP id XAA09365; Fri, 26 Dec 1997 23:46:48 GMT (envelope-from brian@gate.lan.awfulhak.org) Message-Id: <199712262346.XAA09365@awfulhak.demon.co.uk> X-Mailer: exmh version 2.0.1 12/23/97 To: Greg Lehey cc: Nick Holshouser , "Robert J. Lynn Jr." , freebsd-questions@freebsd.org Subject: Re: How do you get pppd to save ip to file? In-reply-to: Your message of "Fri, 26 Dec 1997 14:47:30 +1030." <19971226144730.39862@lemis.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 26 Dec 1997 23:46:47 +0000 From: Brian Somers Sender: owner-freebsd-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > On Thu, Dec 25, 1997 at 10:44:18PM -0500, Nick Holshouser wrote: > > this works for me: > > netstat -rn | tail -1 | awk '{print $2}' > file > > That's mainly luck. You're taking the last line of the netstat > output, but you can't rely on the netstat output to be in any > particular order. Worse than that, it's in order based on the destination address. > I didn't answer this question the first time round because I didn't > understand it. If you're just looking for the IP address of a > specific interface, such as your end of your PPP link, you could do > something like > > # ifconfig ppp0 | grep inet | awk '{print $2}' > file > > Use 'tun0' instead of 'ppp0' if you're using user PPP. If you have > more than one link, of course, this sort of breaks down. > > > note: on my systems netstat nicely puts the line with my IP on the > > bottom, so tail -1 works. > > Do you have a trick to ensure this? I can't say for pppd, but with ppp, a simple ! /usr/local/bin/setIP MYADDR will do the job. Be careful, stdin, stdout and stderr are *not* available to `setIP', and you *must* have '#! /bin/sh' or similar at the top of `setIP'. The script may, for example be: #! /bin/sh echo $1 >/tmp/myfile You may alternatively want to use `!bg /usr/local/bin/setIP MYADDR' so that ppp doesn't wait for the command to complete. > Greg -- Brian , , Don't _EVER_ lose your sense of humour....