bahadur has asked for the wisdom of the Perl Monks concerning the following question:

hi i am making a CLI in Perl. one of the comman issued by users is show interfaces which will list all the interfaces on the machine with this additional information
ID Name Speed Link Status eth0 Ethernet E0 100Mb Full link ok eth1 Ethernet E1 100Mb Full link ok eth2 Ethernet E2 Unknown Unknown eth3 Ethernet E3 Unknown Unknown eth4 Ethernet E4 Unknown Unknown eth5 Ethernet E5 Unknown Unknown
what package do i need to do this?

Replies are listed 'Best First'.
Re: How to list all network interfaces and their ip address in Linux
by Fletch (Bishop) on Jun 14, 2005 at 00:01 UTC

    If you're satisfied to limit yourself to just Linux you should be able to get away rather simply with parsing the output from ifconfig -a and looking for just those interfaces matching /^eth\d+/.

    open( IFCFG, "ifconfig -a |" ) or die "Can't open pipe from ifconfig: +$!\n"; my %ifs; while( <IFCFG> ) { chomp; ## ... } close( IFCFG );

    --
    We're looking for people in ATL

Re: How to list all network interfaces and their ip address in Linux
by kaif (Friar) on Jun 14, 2005 at 01:39 UTC
Re: How to list all network interfaces and their ip address in Linux
by monarch (Priest) on Jun 14, 2005 at 02:06 UTC

    An additional approach is to use Net::SNMP and read in the ifTable MIB table for a device. This would only work for machines that have an snmp agent running on them (such as Cisco routers, or linux machines running something like snmpd).