Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks for that helüp, I now understand better what it is all about... I changed the code to the following:

#!/usr/bin/perl -w use Net::SNMP; use strict; use warnings; use diagnostics; open IPFILE, "ipfile.txt" or die "Can't get IPs - $!\n"; my $community = 'public'; my $ifIndex = ''; # + my $ifDescr = ''; # +13 my $ifDescr2 = ''; # +13 my @serial; my @test2; while ( my $ip = <IPFILE> ) { chomp $ip; print "Got: $ip\n"; + my ( $session, $error ) = Net::SNMP->session( -hostname => $ip, -community => $community, -port => 161 ); my $response; if ( defined( $response = $session->get_table($ifIndex) ) ) { foreach my $index ( values %{$response} ) #values { my $this_desc = "$ifDescr.$index"; my $description; if ( defined( $description = $session->get_request($this_d +esc) ) ) { @serial = values %{$description}; #print @serial; } } foreach my $index ( values %{$response} ) #values { my $this_desc = "$ifDescr2.$index"; my $description2; if ( defined( $description2 = $session->get_request($this_ +desc) ) ) { my @desc = values %{$description2}; #open OUT, ">>desclist.txt"; #print OUT @desc; #close OUT; #open (FILE, ">>desclist.txt"); #print keys %{$description}; #print '.......'; #print values %{$description2}, "\n"; } } print @serial; } $session->close(); }

however the problem is still the same for some reason I really don't get it yet. From my understanding it should be ok when i declare a Var once with my and then i can use it as a global var when i use the same var without the my infront of it . So this should be weorking. When i print the @serial within the same part i assign a value to it it does but like this is doesn't.

In reply to Re^2: SNMP - cont by theroninwins
in thread SNMP - cont by theroninwins

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-06-25 03:59 GMT
Find Nodes?
    Voting Booth?
    My most frequent journeys are powered by:

    Results (81 votes). Check out past polls.