iwanthome has asked for the wisdom of the Perl Monks concerning the following question:

I will use cisco ping mib to implement remote ping. If I use command on linux console
snmpset -v 1 -c pri 99.1.1.1 .1.3.6.1.4.1.9.9.16.1.1.1.3.333 x "63 1 4 +0 47"
it will success. But if I use packet Net::SNMP and code it in perl script
use Net::SNMP ; $session->set_request( -varbindlist => ['.1.3.6.1.4.1.9.9.16.1.1.1.3.333',IPADDRESS,$r_ip +] );
Cisco device will report "Received badValue(3) error-status at error-index 1". I guess maybe the format of IPADDRESS isn't suitable. So how to specify ipaddress in perl script with package Net::SNMP ? thanks!

Replies are listed 'Best First'.
Re: How to code snmpset ?
by naChoZ (Curate) on Mar 23, 2005 at 13:07 UTC

    Where is the line where you init $session as a Net::SNMP object?

    --
    "This alcoholism thing, I think it's just clever propaganda produced by people who want you to buy more bottled water." -- pedestrianwolf

      Sorry I omit it in post. But in perl script,I do it.
Re: How to code snmpset ?
by zengargoyle (Deacon) on Mar 23, 2005 at 15:51 UTC
    you probably want a 4 byte string.
    $ perl -le 'print pack("C*",split(/\./,"127.0.0.1"))' | od -t xC 0000000 7f 00 00 01 0000004
    which i think would match your snmpset 'x' "hex" example. you might also need to change the IPADDRESS to OCTETSTR or whatever Net::SNMP uses for a string of octets.
      thanks! I do it like pack("C*",split(/\./,"127.0.0.1")),and it success.