Re: Set on hex string using python library

François Dumont <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I don't know if you're talking about a get or set request. To be clear, and
for other people who would like to do so, I give you both get and set
requests for a MAC address with snmp python library that I'm using :

GET :

> oid = netsnmp.Varbind('rbAuBaseStationId', '1')
>                                                                 # Replace
> this OID by yours
> HardwareAddress = netsnmp.snmpget(oid, DestHost = '10.0.0.1', Community =
> 'public', Version = 2)         # Replace DesHost, Community and Version by
> yours
> print "HardwareAddress :", ":".join("%02X" % ord(a) for a in
> HardwareAddress[0])
>

SET :

> new_HardwareAddress = eval("'%s'" % raw_input("Please enter the new
> HardwareAddress :\n"))
> oid = netsnmp.Varbind('rbAuConfiguredBaseStationId', '0',
> new_HardwareAddress)                                       # Replace this
> OID by yours
> HardwareAddress = netsnmp.snmpset(oid, DestHost = '10.0.0.1', Community =
> 'public', Version = 2)             # Replace DesHost, Community and Version
> by yours


Everything is working good. For the raw_input, int the command shell, you
have to put \xba\xbe\xba\xbe\xfa\xce. You must put the \x before each value,
and you can't put any 00 (01 works).

I hope everything is clear for everyone now !

François

Le 5 août 2009 18:01, Mike Ayers <[email protected]> a écrit :

> > From: François Dumont [mailto:[email protected]]
> > Sent: Wednesday, August 05, 2009 5:56 AM
>
>
> > Oh yes, sorry, I used "%02s". With "%02X", it's really good !
>
>         So wouldn't 'BA:BE:00:00:FA:CE' also have worked?
>
>
>        HTH,
>
> Mike
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.