From: jheard Date: 2001-11-09T07:05:43+09:00 Subject: [ruby-talk:24701] Re: how to get hostname/MAC address? Christopher Sawtell wrote: > On Fri, 09 Nov 2001 09:12, Tobias DiPasquale wrote: > >>Hi, >> >> Is there a way to get the computer's hostname or Ethernet MAC address >>or IP address from Ruby? >> > > irb(main):002:0> system ( 'hostname -i') > 192.168.2.10 > > irb(main):001:0> system ( '/sbin/ifconfig | grep HWaddr | cut -c39-') > 00:90:27:2D:5A:C5 > > Assuming Unix / Linux & you might consider the hard '39' a bit too kludgy > > -- > Sincerely etc., > Christopher Sawtell > > for Windows, --> IPSocket.getaddress(ENV['MACHINE_NAME']) should do you.