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 it do: gets mac-address of interface.
Works on Debian as expected. But on Mac OS X, im getting error: ``ioctl': Operation not supported on socket (Errno::EOPNOTSUPP)`
Is there anyway to fix/pass this error message & get working ioctl
on Sockets?
http://hintsforums.macworld.com/showthread.php?t=97909
"Following function[s] are not available at Mac OS X:
1) POSIX Timer Library (-librt Real Time) 2) ioctl with command SIOCGIFHWADDR - To get the Mac Address of the network interface."
C'est la vie.