Getting IP in a script

Alan Dayley adayley@adtron.com
Tue, 13 Mar 2001 12:49:41 -0700


This is good.  I had thought of this, though I would have had to study to
figure out how to pull the address out of the rest.  Now I will have to
study to make sure I understand how this script does it.  ;^)

I was hoping for something more like a function call in perl or grabbing a
system parameter somewhere that simply "gave" me the address.  Is there
nothing "cleaner" than grepping ifconfig output?

Alan

At 10:34 AM 3/13/01 -0700, you wrote:
>
>for each $i which is an interface
>
>/sbin/ifconfig eth$i | grep addr: | cut -f2 -d : | cut -f1 -d ' '
>
>~Deepak
>
>On Mar 13 2001, at 10:25, Alan Dayley was caught saying:
>> 
>> I have a linux box with multiple NICs.  It uses DHCP to get it's IP address
>> for one of the network connections.  I would like a script (perl preferred,
>> other fine) that will get the IP address assigned to a specific NIC.  I
>> can't seem to find the answer online anywhere...
>> 
>> Alan
>> 
>> /------------------------------------------
>> |Alan Dayley             www.adtron.com
>> |Software Engineer       602-735-0300 x331
>> |ADayley@adtron.com
>> |
>> |Adtron Corporation         
>> |3710 E. University Drive, Suite 5
>> |Phoenix, AZ  85034
>> \-------------------------------------------
>> 
>> 
>> _______________________________________________
>> Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
>> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
>
>-- 
>Deepak Saxena - deepak@csociety.purdue.edu - phone://602.790.0500
>
>Code Monkey, MontaVista Software, Inc. - THE Embedded Linux Experts
>
>call me 'evil' call me 'tide is on your side' anything that you want
>anybody knows you can conjure anything by the dark of the moon
>  - Tori Amos, "Suede"
>
>_______________________________________________
>Plug-devel mailing list  -  Plug-devel@lists.PLUG.phoenix.az.us
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
>
>
>
/------------------------------------------
|Alan Dayley             www.adtron.com
|Software Engineer       602-735-0300 x331
|ADayley@adtron.com
|
|Adtron Corporation         
|3710 E. University Drive, Suite 5
|Phoenix, AZ  85034
\-------------------------------------------