[wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Joe Fl
Hi Željko,

I tried it but nothing returned.

ree-1.8.7-2010.02 :003`> scutil --get ComputerName

Is the above correct?

Thank you,
Joe

On Oct 20, 10:54 am, Željko Filipin 
wrote:
> On Thu, Oct 20, 2011 at 4:47 PM, Joe Fl  wrote:
> > This is a ruby question but how do I get the name of my MAC using
> > ruby.
>
> $ irb> `scutil --get ComputerName`
>
>  => "mac\n"
>
> My macnine name is "mac".
>
> Željko
> --
> watir.com - community manager
> watir.com/book - author
> watirpodcast.com - host

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Joe Fl
Hi Željko,

I corrected it but still nothing.  What does 'scutil' mean?

Thank you,
Joe

On Oct 20, 11:18 am, Željko Filipin 
wrote:
> On Thu, Oct 20, 2011 at 5:12 PM, Joe Fl  wrote:
> > ree-1.8.7-2010.02 :003`> scutil --get ComputerName
> > Is the above correct?
>
> No. You do not have backticks:
>
> `scutil --get ComputerName`
>
> More information on how to call bash commands from ruby:
>
> http://stackoverflow.com/questions/2232/calling-bash-commands-from-ruby
>
> Željko

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Chuck van der Linden
On Oct 20, 7:47 am, Joe Fl  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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Chuck van der Linden
On Oct 20, 10:09 am, Joe Fleck  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 
> 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.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Get machine name for MAC

2011-10-21 Thread Joe DiMauro
Joe,

Here's a partial answer to why
   puts ENV["COMPUTERNAME"]
returned nil.

Not every environment variable that is available on Windows is also on
OSX (or Linux).

To see which Env variables are available on your platform try this
code, the results will differ form Windows, to OSX, to Linux.

irb
ENV.each do | key, value |
puts key.to_s + " = "  + value.to_s
end


On Oct 20, 8:47 am, Joe Fl  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
>
> any help would be appreciated.
>
> Thank you,
> Joe

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


[wtr-general] Re: Get machine name for MAC

2011-10-27 Thread Dan
I've had pretty good luck with this below.  Although you do need to make 
some decisions based on what os you're using which has been mentioned in 
some other posts here.

https://github.com/djberg96/sys-uname

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Željko Filipin
On Thu, Oct 20, 2011 at 5:12 PM, Joe Fl  wrote:
> ree-1.8.7-2010.02 :003`> scutil --get ComputerName
> Is the above correct?

No. You do not have backticks:

`scutil --get ComputerName`

More information on how to call bash commands from ruby:

http://stackoverflow.com/questions/2232/calling-bash-commands-from-ruby

Željko

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Željko Filipin
On Thu, Oct 20, 2011 at 6:09 PM, Joe Fl  wrote:
> What does 'scutil' mean?

This is all I know about it:

http://www.google.com/search?q=scutil

Željko

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Get machine name for MAC

2011-10-20 Thread Joe Fleck
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 wrote:

> On Oct 20, 7:47 am, Joe Fl  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.
>
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com


Re: [wtr-general] Re: Get machine name for MAC

2011-10-20 Thread John Fitisoff
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 
To: watir-general@googlegroups.com
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  wrote:

On Oct 20, 7:47 am, Joe Fl  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.
>
>watir-general@googlegroups.com
>http://groups.google.com/group/watir-general
>watir-general+unsubscr...@googlegroups.com
>
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.
 
watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com