Forum: Ruby Re: snmp error

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Brian C. (Guest)
on 2007-06-27 19:31
(Received via mailing list)
> the mac address is visualized as shown
> 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(":")
This topic is locked and can not be replied to.