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

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.

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

    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

Re^5: Net::SNMP ASN1 Type error
by kcott (Archbishop) on Oct 12, 2010 at 10:56 UTC

    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

      Thanks for your help Ken. I neglected to mention that this is running on ActiveState Perl. I copied my code and ran it on OSX in a shell and had no issues with the INTEGER constant. I re-installed the Net::SNMP module on my Activestate Windows box, but still get the same error. In this case, probably not a huge deal, I'll do a work around by using the system command to run snmpset in a dos prompt. I just hate doing that, seems slower and more clunky. Thanks again.

        I also have Activestate (v5.10.1) on Windows XP and the above code from Ken works fine for me - no issue with bareword INTEGER.

        What version of Net::SNMP are you using - I'm at v6.0.0. I've seen this error in the past with older versions of Net::SNMP, the fix was as described above in the 'use' line:

        use Net::SNMP qw(:asn1 :snmp);

        I have a Windows box but I'm running Strawberry Perl. Worked fine here too:

        C:\_\tmp>net_snmp_problem.pl No response from remote host "127.0.0.1" C:\_\tmp>

        The earlier output was from Cygwin.

        I've got Perl 5.12.0 on both and Net::SNMP 6.0.1 on both. I didn't have Net::SNMP running on either so they're both fresh installs and the latest version.

        And, unfortunately, that's me completely out of ideas.

        -- Ken

        I was able to get this to work by using the asn.1 value for INTEGER (2) and OCTET_STRING (4).