Getting IP in a script

Lucas Vogel lvogel@exponent.com
Tue, 13 Mar 2001 12:06:44 -0800


To find that glibc call, would it help to look in the sources of the
ifconfig program? I'm curious as to the process of finding the appropriate
function call here...

> -----Original Message-----
> From: Deepak Saxena [mailto:deepak@csociety.purdue.edu]
> Sent: Tuesday, March 13, 2001 1:01 PM
> To: plug-devel@lists.PLUG.phoenix.az.us
> Subject: Re: Getting IP in a script
> 
> 
> 
> 
> I'm 95% sure there's a glibc call that will do this for you, which
> means there's probably a perl equivalent.  Will look it up when I get 
> a chance.
> 
> ~Deepak
> 
> On Mar 13 2001, at 12:49, Alan Dayley was caught saying:
> > 
> > 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
> > \-------------------------------------------
> > 
> > 
> > _______________________________________________
> > 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
>