Date: Fri, 26 Dec 1997 23:46:47 +0000 From: Brian Somers <brian@awfulhak.org> To: Greg Lehey <grog@lemis.com> Cc: Nick Holshouser <nickh@ncnatural.com>, "Robert J. Lynn Jr." <root@techster.dyn.ml.org>, freebsd-questions@freebsd.org Subject: Re: How do you get pppd to save ip to file? Message-ID: <199712262346.XAA09365@awfulhak.demon.co.uk> In-Reply-To: Your message of "Fri, 26 Dec 1997 14:47:30 %2B1030." <19971226144730.39862@lemis.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <brian@Awfulhak.org>, <brian@FreeBSD.org>, <brian@OpenBSD.org> <http://www.Awfulhak.org> Don't _EVER_ lose your sense of humour....
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712262346.XAA09365>