From owner-freebsd-questions@FreeBSD.ORG Tue Apr 29 02:08:37 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6B6037B401 for ; Tue, 29 Apr 2003 02:08:37 -0700 (PDT) Received: from supermail.mweb.co.za (supermail.mweb.co.za [196.2.53.171]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F00C43F3F for ; Tue, 29 Apr 2003 02:08:36 -0700 (PDT) (envelope-from dj_boris@mail.ru) Received: from [196.7.205.235] (helo=d) by supermail.mweb.co.za with smtp (Exim 3.22 #1) id 19AQyJ-0007GD-00; Tue, 29 Apr 2003 11:00:20 +0200 Message-ID: <00c101c30e2e$d306f980$6300a8c0@fmelectro.co.za> From: "DJ Boris" To: "Christian Stigen Larsen" , "Tom Smith" , "Lowell Gilbert" References: <01de01c30dd1$5c5d4c10$6300a8c0@fmelectro.co.za> <20030428223104.GA1043@sublevel3.org> Date: Tue, 29 Apr 2003 10:56:41 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 cc: freebsd-questions Subject: Re: extract IP address and feed it into a command X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Apr 2003 09:08:38 -0000 hi guys, I would like to thank you for all your help... you pointed me in the right direction. here is what worked for me: ifconfig tun0 | grep xxx.x | cut -d " " -f2 ifconfig tun0 | grep xxx.x | awk '/inet/ {print $2}' ifconfig tun0 | grep xxx.x | awk '{print $2}' xxx.x - this is the first part of my IP. it always starts with that xxx.x number. grep gets it from the ifconfig and then all it takes is string munching... AND AGAIN - THANK YOU VERY MUCH dj boris ----- Original Message ----- From: "Christian Stigen Larsen" To: Sent: Tuesday, April 29, 2003 12:31 AM Subject: Re: extract IP address and feed it into a command > Quoting DJ Boris (dj_boris@mail.ru): > | I need to extract my IP address [...] assigned by my ISP [...] > | I know that my IP always starts with zzz.zzz and if I run > | > | "ifconfig | grep zzz.zzz" > > >From the top of my head, I don't know any programs that automatically spits > out IP addresses. But you could always combine ifconfig with awk. Say the > interface you need to query is xl0, then you might do: > > $ ifconfig xl0 inet | awk '/inet/ {print $2}' > > This prints "10.0.0.2", which is the IP assigned to my box by the DHCP server. > > I don't know if this is exactly what you need, but at least it should give you > some idea on using awk in such cases. Play around, and you'll probably get > something working (or, possibly, someone else on the list gives you some > better alternative). > > Dig up some info on awk if you've never heard about it before. > > -- > Christian Stigen Larsen -- http://sublevel3.org/~csl/ -- mob: +47 98 22 02 15 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >