Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Read network configuration on FreeBSD

by josef (Acolyte)
on Oct 10, 2012 at 17:41 UTC ( #998272=note: print w/ replies, xml ) Need Help??


in reply to Re: Read network configuration on FreeBSD
in thread Read network configuration on FreeBSD

My script is now:

#! /usr/bin/perl -w use Data::Dumper::Simple; use IO::Interface::Simple; my @interfaces = IO::Interface::Simple->interfaces; #print Dumper @interfaces; for my $if (@interfaces) { next if $if =~ /usb|iwn|lo/; print "interface = " . $if . "\n"; print "addr = " . $if->address . "\n"; print "broadcast = " . $if->broadcast ."\n"; print "netmask = " . $if->netmask ."\n"; print "dstaddr = " . $if->dstaddr . "\n"; # line 15 print "hwaddr = " . $if->hwaddr . "\n"; # line 16 print "mtu = " . $if->mtu . "\n"; print "metric = " . $if->metric . "\n"; print "index = " . $if->index . "\n"; print "is running\n" if $if->is_running; print "is broadcast\n" if $if->is_broadcast; print "is p-to-p\n" if $if->is_pt2pt; print "is loopback\n" if $if->is_loopback; print "is promiscuous\n" if $if->is_promiscuous; print "is multicast\n" if $if->is_multicast; print "is notrailers\n" if $if->is_notrailers; print "is noarp\n" if $if->is_noarp; } and the result is like: interface = re0 addr = 172.21.100.29 broadcast = 172.21.100.255 netmask = 255.255.255.0 Use of uninitialized value in concatenation (.) or string at int.pl li +ne 15 dstaddr = hwaddr = c8:0a:a9:93:87:25 mtu = 1500 metric = 0 index = 6 is running is broadcast is multicast Your vendor has not defined IO::Interface macro IFF_NOTRAILERS at /usr +/local/lib/perl5/site_perl/5.14.2/mach/IO/Interface/Simple.pm line 11 +7


Comment on Re^2: Read network configuration on FreeBSD
Download Code
Re^3: Read network configuration on FreeBSD
by VinsWorldcom (Vicar) on Oct 10, 2012 at 18:08 UTC

    Just check if the values are defined before printing them. I don't have a linux system so I don't know why IO::Interface (which does't compile for me on Windows/Strawberry) doesn't return a dstaddr or hwaddr.

    printf "dstaddr = %s\n", defined($if->dstaddr) ? $if->dstaddr : ''; +# line 15 printf "hwaddr = %s\n", defined($if->hwaddr) ? $if->hwaddr : ''; # +line 16
Re^3: Read network configuration on FreeBSD
by josef (Acolyte) on Oct 10, 2012 at 18:09 UTC
    Hmm, the script read now the interface parameters but not for the IP addresses as alias.

    I will be very happy to get the media and the speed of the interface:

    media: Ethernet autoselect (100baseTX <full-duplex>)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998272]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-05 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls