Reputation: 57
Hey Im trying to get the MAC-address via ipNetToMediaPhysAddress which works fine when using the netsnmp.snmpget command but when saving that into a variable(tuple?) and printing it out via "print" the mac-address looks like this.
('\x00\n\xb7\x9c\x93\x80',)
Code looks like this,
mac = netsnmp.Varbind("ipNetToMediaPhysAddress."+i+"."+ipadd)
macadd = netsnmp.snmpget(mac, Version = 2, DestHost = ip, Community = comm)
print '%-15s' % macadd
So what do I need to do? I just want it to look like a normal MAC address.
Upvotes: 0
Views: 555
Reputation: 415
Maybe a call to hexlify is enough
from binascii import hexlify
mac = netsnmp.Varbind("ipNetToMediaPhysAddress."+i+"."+ipadd)
macadd = netsnmp.snmpget(mac, Version = 2, DestHost = ip, Community = comm)
print hexlify(macadd[0])
Upvotes: 1