Re: How to determine local IP
*- On 21 Jun, Rick Macdonald wrote about "Re: How to determine local IP"
> On Mon, 21 Jun 1999, Ramesh Natarajan wrote:
>
>> This message was sent from Geocrawler.com by "Ramesh Natarajan" <nram@rocketmail.com>
>>
>> Hi, Once dialed in, how to determine the local (dynamically assigned)
>> IP id? I know pppd invokes ip-up with the local IP. But outside that,
>> is there a env variable, API or a file that holds returns this info?
>
> I would use ip-up to write a file that contains the IP. However, I used to
> use the following sometimes. I don't use ppp anymore, but this might
> still work. awk can probably do it more elegantly...
>
> /sbin/ifconfig | grep P-t-P | cut -d: -f2 | cut -d" " -f1
>
Another hack using awk, not any more elegan just goes to show that there
are more than one way to do things
ifconfig ppp0 | grep inet | awk -F":" '{print $2}' | awk -F" " '{print $1}'
--
Brian
---------------------------------------------------------------------
Mechanical Engineering servis@purdue.edu
Purdue University http://www.ecn.purdue.edu/~servis
---------------------------------------------------------------------
Reply to: