in reply to Net::SNMP::Interfaces how to print the error()
To clarify what hexcoder said...
Based on the documentation, $Net::SNMP::Interfaces::error is only set if you haven't used RaiseError => 1. You should be able to do one of the following:
#!/usr/bin/perl use strict; use warnings; use Net::SNMP::Interfaces; use Data::Dumper qw(Dumper); my $interfaces = Net::SNMP::Interfaces->new( Hostname => '127.0.0.1', Community => 'public', Port => '1161', RaiseError => 1, # Errors are fatal ); my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);
#!/usr/bin/perl use strict; use warnings; use Net::SNMP::Interfaces; use Data::Dumper qw(Dumper); my $interfaces = Net::SNMP::Interfaces->new( Hostname => '127.0.0.1', Community => 'public', Port => '1161', ) or die $Net::SNMP::Interfaces::error; my @ifnames = $interfaces->all_interfaces(); print Dumper (\@ifnames);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Net::SNMP::Interfaces how to print the error()
by thanos1983 (Parson) on Jun 04, 2014 at 20:41 UTC |
In Section
Seekers of Perl Wisdom