Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Read network configuration on FreeBSD

by VinsWorldcom (Parson)
on Oct 10, 2012 at 17:09 UTC ( #998265=note: print w/replies, xml ) Need Help??

in reply to Read network configuration on FreeBSD

Seplling? That says 'addrese', I assume it should be 'address'?

And if you're using the synopsis directly from the POD for IO::Interface, you probably shouldn't mix the new and old API.

  • Comment on Re: Read network configuration on FreeBSD

Replies are listed 'Best First'.
Re^2: Read network configuration on FreeBSD
by josef (Acolyte) on Oct 10, 2012 at 17:24 UTC
    Ups, I correct the line with 'addrese' to 'address' but the error still remain :
    Can't locate object method "address" via package "re0" (perhaps you fo +rgot to load "re0"?) at line 25.
Re^2: Read network configuration on FreeBSD
by josef (Acolyte) on Oct 10, 2012 at 17:41 UTC
    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

      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
      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://998265]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2018-06-25 10:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.