There's probably some more elegant way of doing it but think something like
this would work for post-95 Windows builds :
mac = `ipconfig /all`.match(/Physical
Address.*/).to_s.split(':').last.strip.gsub('-',':').downcase
You could do something similar on unix by calling ifconfig and then parsing the
result in a similar way.
________________________________
From: Joe Fleck <[email protected]>
To: [email protected]
Sent: Thursday, October 20, 2011 10:09 AM
Subject: Re: [wtr-general] Re: Get machine name for MAC
I am looking for the name of my MAC machine to possibly use in a script.
On Thu, Oct 20, 2011 at 12:47 PM, Chuck van der Linden <[email protected]> wrote:
On Oct 20, 7:47 am, Joe Fl <[email protected]> wrote:
>> Hi,
>>
>> This is a ruby question but how do I get the name of my MAC using
>> ruby.
>>
>> I have found:
>>
>> require 'socket'
>> puts Socket.gethostname
>>
>> (not what I am looking for)
>>
>> puts ENV["COMPUTERNAME"]
>>
>> puts ENV['USERDOMAIN']
>> puts ENV['LOGONSERVER']
>>
>> they all return nil
>>
>
>I don't know if any of those are set (surely I doubt 'domain' or
>'loginserver' since I think those are unique to a system that is
>logging into a windows domain or active-directory.)
>
>You might try HOSTNAME
>
>Are you looking for the name set for the system under networking
>settings on the WINS tab, or under sharing settings for Bonjour? or
>set somewhere else?
>
>
>--
>Before posting, please read http://watir.com/support. In short: search before
>you ask, be nice.
>
>[email protected]
>http://groups.google.com/group/watir-general
>[email protected]
>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]