[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: snmp error

Brian Candler

6/27/2007 3:22:00 PM

> the mac address is visualized as shown
>
> 1.3.6.1.2.1.2.2.1.6.1 �½g OCTET STRING
>
> instead of 0:10:83:fd:dd:67.
>
> How can I fix it?

The trouble is that you are printing the raw 6 byte string (note that hex 67
is the ASCII code for a lower-case 'g')

So you just need to convert it into 12 hex digits:

a = "\x00\x10\x83\xfd\xdd\x67"
puts a.unpack("H*").first

Here's one way to add the colons:

a = "\x00\x10\x83\xfd\xdd\x67"
puts a.unpack("H2H2H2H2H2H2").join(":")