Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 = broadcast = netmask = Use of uninitialized value in concatenation (.) or string at 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/ line 11 +7

Replies are listed 'Best First'.
Re^3: Read network configuration on FreeBSD
by VinsWorldcom (Parson) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998272]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2017-01-21 02:52 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (180 votes). Check out past polls.