in reply to Re: Net::SNMP ASN1 Type error
in thread Net::SNMP ASN1 Type error

Thanks for the response Ken. I updated the original post to make it more readable. My use line is below.

use Net::SNMP;

Replies are listed 'Best First'.
Re^3: Net::SNMP ASN1 Type error
by kcott (Archbishop) on Oct 11, 2010 at 20:02 UTC

    That line looks fine. INTEGER should be exported by default. Please do the following:

    Add:

    use strict; use warnings;

    before that line.

    Quote the bareword private.

    Run it again and post any error output.

    -- Ken

      Ok, I have changed the code to this:

      use strict; use warnings; use Net::SNMP; my $ip = XXX.XXX.XXX.XXX; my $SESSION = Net::SNMP->session (-hostname=>$ip, -community=>"private +"); $SESSION->set_request(-varbindlist=> ['1.3.6.1.4.1.6080.3.1.2.4.0", IN +TEGER, 1]); print $SESSION->error();

      When I run that I get the following error: Bareword "INTEGER" not allowed while "strict subs" in use at line 19. If I put quotes around INTEGER, I get the original error of ASN.1 Type Integer unknown.

        Mismatched quotes:

        '1.3.6.1.4.1.6080.3.1.2.4.0"

        Should be:

        '1.3.6.1.4.1.6080.3.1.2.4.0'

        -- Ken

        Your problem was niggling me so I tried it myself.

        Other than the $ip value, I used exactly what you have (with the mismatched quote problem fixed).

        Here's my code:

        #!perl use strict; use warnings; use Net::SNMP; my $ip = '127.0.0.1'; my $SESSION = Net::SNMP->session (-hostname=>$ip, -community=>"private +"); $SESSION->set_request(-varbindlist=> ['1.3.6.1.4.1.6080.3.1.2.4.0', IN +TEGER, 1]); print $SESSION->error();

        And here's the output:

        $ net_snmp_problem.pl No response from remote host "127.0.0.1"

        As you can see, no problem with INTEGER.

        Furthermore, when I ran it without fixing the quotes, I got:

        Can't find string terminator "'" anywhere before EOF at ./net_snmp_pro +blem.pl line 12.

        which suggests that you're posting different code to what you're actually running.

        Anyway, if you're still having difficulties, my best advice would be to re-install Net::SNMP.

        -- Ken