Re: Finding IP address programmatically?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 12 June 2003 15:27, bhaskar wrote:
> hi,
> The easiest way to find the ip address of an interface is to read
> /etc/sysconfig/network-scripts/ifcfg-xxx.  Where xxx is the interface
> name(eth0, for eg).  You can also get the ip address using ioctl.
you think redhat is the only dist?

something like 

/sbin/ip addr show dev eth0 | grep "inet " | cut -c 10- | cut -f 1 -d "/"

is better ... but I would do a regex in a realworld application, as the format 
may not 100% the same at all version of "ip"


- -- 
Regards,
Robert
- ----------------
Robert Penz
robert.penz AT outertech.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE+6IYY8tTsQqJDUBMRAkr+AJwLu/KflDFUYFBJNSh+gwdzELIuWgCfcOjb
fSTe9LGa3ioc9srkE2ShdAw=
=A9Eu
-----END PGP SIGNATURE-----

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux