Good time of day.
Ruby Code:
def hw_address(iface)
sock = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM,0)
buf = [iface,""].pack('a16h16')
sock.ioctl(SIOCGIFHWADDR, buf);
sock.close
return buf[18..24].to_etheraddr
end
puts hw_address('lo0')
What he does: gets the mac address of the interface.
Powered by Debian, as expected. But on Mac OS X it becomes an error for them: `` ioctl ': the operation is not supported on the socket (Errno :: EOPNOTSUPP) `
Do I still need to fix / pass this error message and get work ioctlon sockets?
source
share