0

I am trying to use the netsnmp library to snmpset a attribute I get an error

robm@PC2303VM:~/code/python/snmp$ ./tester2.py
  File "./tester2.py", line 5
    ipaddr=netsnmp.Varbind('.1.3.6.1.2.1.69.1.3.1.0',172.168.100.2,'IPADDRESS')
                                                               ^
SyntaxError: invalid syntax

now from the command line

snmpset -v2c -c private 10.1.1.8 .1.3.6.1.2.1.69.1.3.1.0 a 172.168.100.2

works just fine and quoting "172.168.100.2" gives a different error TypeError: expected string or Unicode object, NoneType found

#!/usr/bin/python
import netsnmp


ipaddr=netsnmp.Varbind('.1.3.6.1.2.1.69.1.3.1.0',172.168.100.2,'IPADDRESS')
netsnmp.snmpset(ipaddr, Version=2, DestHost="10.1.1.8", Community="private")

filename=netsnmp.Varbind('.1.3.6.1.2.1.69.1.3.2.0', './robertme/Q2Q_REL_7_2_2_2015_04_07_T1935.bin','STRING')
netsnmp.snmpset(filename, Version=2, DestHost='10.1.1.8', Community='private' )

any Ideas on how to format that correctly?

RobM
  • 747
  • 5
  • 12
  • I've looked through the source of the Varbind class (https://github.com/haad/net-snmp/blob/master/python/netsnmp/client.py). Are you sure you're intending to create an object with properties, tag='.1.3.6.1.2.1.69.1.3.1.0', iid='172.168.100.2' and val='IPADDRESS'. That is what the constructor is trying to do! – Matt Davidson Apr 14 '15 at 18:04
  • yes that attribute needs to be an IPADDRESS but for some reason it does'nt like what i have entered – RobM Apr 14 '15 at 21:56

0 Answers0