theroninwins has asked for the wisdom of the Perl Monks concerning the following question:
the @test1 should print the @serial stuff but it is not working maybe because i cannot get the stuff to be global?? Anyone an idea on how to do it??#!/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 = '1.3.6.1.2.1.47.1.1.1.1.6'; #1.3.6.1.2.1.2.2.1.1 + 1.3.6.1.2.1.47.1.1.1.1.12 my $ifDescr = '1.3.6.1.2.1.47.1.1.1.1.11'; #1.3.6.1.2.1.47.1.1.1.1. +13 my $ifDescr2 = '1.3.6.1.2.1.47.1.1.1.1.2'; #1.3.6.1.2.1.47.1.1.1.1. +13 my @test1; 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) ) ) { my @serial = values %{$description}; #open OUT, ">>serlist.txt"; #print OUT @serial; #close OUT; #open (OUT, ">>serlist.txt"); #print keys %{$description}; #print '.......'; #print values %{$description}, "\n"; my @test1 = @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 my @test1; } } $session->close(); }
Edited by Chady -- code tags addition.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SNMP - cont
by davido (Cardinal) on Aug 27, 2004 at 13:56 UTC | |
by theroninwins (Friar) on Aug 30, 2004 at 07:28 UTC | |
by theroninwins (Friar) on Aug 30, 2004 at 12:44 UTC | |
by theroninwins (Friar) on Sep 02, 2004 at 05:49 UTC | |
|
Re: SNMP - cont
by Joost (Canon) on Aug 27, 2004 at 13:17 UTC | |
by theroninwins (Friar) on Aug 27, 2004 at 13:20 UTC | |
by Anonymous Monk on Aug 27, 2004 at 13:34 UTC | |
by theroninwins (Friar) on Aug 27, 2004 at 13:38 UTC | |
|
Re: SNMP - cont
by Eimi Metamorphoumai (Deacon) on Aug 27, 2004 at 13:37 UTC | |
by theroninwins (Friar) on Aug 27, 2004 at 13:43 UTC |