Net::SNMP how to specify hex in set_request

From: Ben Thompson (bt4_at_york.ac.uk)
Date: 03/26/04

  • Next message: Roel van der Steen: "Re: help on error log"
    Date: Fri, 26 Mar 2004 09:01:22 +0000
    
    

    Hi

    I would like to send a hex value set request using the Net::SNMP perl
    module (do do with modifying vlans on a HP switch). Using net-snmp I
    can issue the following command :

    # snmpset hostname dot1qVlanStaticEgressPorts.1 x 'ffbfffc0'

    I would like to do the same thing from a perl module, but so far I have
    not had any success. The main problem I think is that I don't know how
    to specify that I want to send a value in hex. Would someone be able to
    offer me some advice?

    Many Thanks

    Ben

    code :-

    #!/usr/bin/perl

    use strict;
    use Net::SNMP;

    my $community_string = "whatever";
    my $dot1qVlanStaticEgressPorts = "1.3.6.1.2.1.17.7.1.4.3.1.2";
    my $switch_ip_address = "i will put the ip address in here"

    # Initialise "session" object with ip address and community string
    my ($session, $error) = Net::SNMP->session(Hostname =>
    $switch_ip_address, Community => $community_string);
    die "session error: $error" unless ($session);

    my $result = $session->set_request("$dot1qVlanStaticEgressPorts.1",
    ???????????????, 0xffbfffc0);
    die "set_request error: ".$session->error unless (defined $result);

    $session->close;


  • Next message: Roel van der Steen: "Re: help on error log"

    Relevant Pages

    • Re: Trying to pad a 40 digit number with zeros with no luck
      ... It  looks like you have this taking the 13th bit and turning it on, ... -a is to tell perl to split each line ... I split the input into 2 hex numbers: ... digits and followed by ". ...
      (comp.unix.shell)
    • Re: Replacing unicode characters
      ... > i artikel c0goke$l8b$2@wisteria.csv.warwick.ac.uk, skrev Ben Morrow... A 2-digit hex number, say 0x82, can also ... strings as sequences of 8-bit bytes. ... The fact that if you treat it as textual Perl ...
      (comp.lang.perl.misc)
    • Re: hexadecimal addition
      ... case you don't have a number, you have an unquoted string. ... You tell Perl a number written in your source file is hex by preceding ... Please read perldoc perldata. ...
      (comp.lang.perl.misc)
    • FAQ 4.3 Why isnt my octal data interpreted correctly?
      ... Perl only understands octal and hex numbers as such when they occur as ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ... so please include relevant details for corrections ...
      (comp.lang.perl.misc)
    • FAQ 4.3 Why isnt my octal data interpreted correctly?
      ... Perl only understands octal and hex numbers as such when they occur as ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ... corrections to examples that do not work on particular platforms. ...
      (comp.lang.perl.misc)