From owner-freebsd-questions Thu Dec 25 21:11:24 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id VAA23100 for questions-outgoing; Thu, 25 Dec 1997 21:11:24 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from freebie.lemis.com (gregl1.lnk.telstra.net [139.130.136.133]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id VAA23031 for ; Thu, 25 Dec 1997 21:09:57 -0800 (PST) (envelope-from grog@lemis.com) Received: (from grog@localhost) by freebie.lemis.com (8.8.8/8.8.7) id OAA00606; Fri, 26 Dec 1997 14:47:30 +1030 (CST) (envelope-from grog) Message-ID: <19971226144730.39862@lemis.com> Date: Fri, 26 Dec 1997 14:47:30 +1030 From: Greg Lehey To: Nick Holshouser Cc: "Robert J. Lynn Jr." , freebsd-questions@FreeBSD.ORG Subject: Re: How do you get pppd to save ip to file? References: <199712260308.DAA08994@techster.dyn.ml.org> <34A32812.299C@ncnatural.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.84e In-Reply-To: <34A32812.299C@ncnatural.com>; from Nick Holshouser on Thu, Dec 25, 1997 at 10:44:18PM -0500 Organisation: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 WWW-Home-Page: http://www.lemis.com/~grog 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. 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? Greg