this full code
#!/usr/bin/perl use strict; use Net::SNMP; my @ips=qw(12 28 11); foreach my $k (@ips) { my $hostname = "10.0.0.$k"; my $password = "public"; my %param = ( sysUpTime => '.1.3.6.1.2.1.1.3', sysName => '.1.3.6.1.2.1.1.5', ifDescr => '.1.3.6.1.2.1.2.2.1.2', ifSpeed => '.1.3.6.1.2.1.2.2.1.5', ifPhysAddress => '.1.3.6.1.2.1.2.2.1.6', hrPrinterStatus => '.1.3.6.1.2.1.25.3.5.1.1', hrPrinterDetectedErrorState => '.1.3.6.1.2.1.25.3.5.1.2', hrDeviceDescr => '.1.3.6.1.2.1.25.3.2.1.3', prtCoverStatus => '.1.3.6.1.2.1.43.6.1.1.3', prtMarkerLifeCount => '.1.3.6.1.2.1.43.10.2.1.4' ); my $status; my ( my $session, my $error ) = Net::SNMP->session ( Hostname => $host +name, Community => $password , Version => 1 ); if (!defined($session)) { printf("ERROR: %s.\n", $error); exit 1; } my $result = $session->get_next_request ( varbindlist => [ $param{sysN +ame}.$1] ); die "request error: ".$session->error unless ( defined $r +esult ); ( $param{sysName}, my $name1 ) = each %$result; unless ( $param{sysNam +e} =~ /$param{sysName}(.*)/ ) { last; } $session->close; print "$k $name1\n"; } exit 0;
host 10.0.0.28 power off
I made a mistake. Programm give an error
request error: No response from remote host '10.0.0.28' at ps-test.pl line 21.

In reply to Re^2: Problems with the module Net::SNMP by tolyan77
in thread Problems with the module Net::SNMP by tolyan77

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.