On Oct 20, 10:09 am, Joe Fleck <[email protected]> wrote:
> 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:
>
I get that you want the name of your Macintosh system and not the MAC
address or somesuch networking detail.
Really, the hostname returned by the Socket gem (the first thing you
said you tried) is your most likely candidate for this.
There is nothing I can find in the environment (unless you were to
specifically set it, and I'm new enough to the mac that I'd have no
idea how to do that other than googling for the info)
You can see everything in the ruby 'Environment' this way
ENV.to_hash.each do |key, value|
puts("#{key}\t#{value}")
end
There's a lot there, but I didn't see anything useful on my system
(which is a macbook pro running lion)
If the hostname isn't returning something useful, you could always try
changing it to be useful (although I have virtually no idea what you
might break by doing that, but the info I says tends to indicate it
should be the same as the computername anyway.. If you've recently
renamed the system but not rebooted, potentially you might be looking
at an old copy of the info in a terminal session.
At your own risk you can try changing the hostname
Here’s how to change your Mac hostname with the command line and make
it permanent:
scutil –set HostName new_hostname
Simply replace new_hostname with whatever you want your hostname to be
changed to, for example I want to change my Mac’s hostname to
MacBookPro, I will use this command:
scutil –set HostName MacBookPro
Note that capitalization is important here.
once you do that, logout of your terminal session and create a new one
and you should see the new hostname there.
--
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]