[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Is there a way to obtain the computer name using ruby?

Mike Johnson

4/15/2008 8:49:00 PM

Hi, all

I am using ruby with watir to make some small scripts. I want to obtain
the name of the computer where my script is running from. Is there a
way to obtain the computer name using ruby?

Thanks
--
Posted via http://www.ruby-....

7 Answers

Glen Holcomb

4/15/2008 8:55:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Tue, Apr 15, 2008 at 2:48 PM, Mike Johnson <freezingsmile@gmail.com>
wrote:

> Hi, all
>
> I am using ruby with watir to make some small scripts. I want to obtain
> the name of the computer where my script is running from. Is there a
> way to obtain the computer name using ruby?
>
> Thanks
> --
> Posted via http://www.ruby-....
>
>
Socket.gethostname

--
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can't hear a word you're saying."

-Greg Graffin (Bad Religion)

Phillip Gawlowski

4/15/2008 9:03:00 PM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike Johnson wrote:
| Hi, all
|
| I am using ruby with watir to make some small scripts. I want to obtain
| the name of the computer where my script is running from. Is there a
| way to obtain the computer name using ruby?
|
| Thanks

Well, there's ENV['USERDOMAIN'], and ENV['LOGONSERVER'], taken from the
environment variables.

Those might not be useful in an LDAP / Active directory environment,
though. But then an LDAP gem should have an API to get the computer's name.

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

~ Thank you. before I begin, I'd like everyone to notice that my report
is in a professional, clear plastic binder...When a report looks this
good, you know it'll get an A. That's a tip kids. Write it down. -- Calvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail....

iEYEARECAAYFAkgFF/UACgkQbtAgaoJTgL+YmgCggd8DUvR4DK4sEk9QY5Ui5Ivo
yo0AnR62VqtY1BLjbSzXnSeKDhs5Al2x
=MXVE
-----END PGP SIGNATURE-----

Siep Korteling

4/15/2008 9:03:00 PM

0

Glen Holcomb wrote:
> On Tue, Apr 15, 2008 at 2:48 PM, Mike Johnson <freezingsmile@gmail.com>
> wrote:
>
>>
> Socket.gethostname
>
> --
> "Hey brother Christian with your high and mighty errand, Your actions
> speak
> so loud, I can't hear a word you're saying."
>
> -Greg Graffin (Bad Religion)

Did not know that one, thid works too:

ENV["COMPUTERNAME"]

regards,

Siep
--
Posted via http://www.ruby-....

James Britt

4/15/2008 9:04:00 PM

0

Mike Johnson wrote:
> Hi, all
>
> I am using ruby with watir to make some small scripts. I want to obtain
> the name of the computer where my script is running from. Is there a
> way to obtain the computer name using ruby?
>
> Thanks


name = `hostname`

More or less.

Don't recall if this works in Windows, but there should be something
similar that returns machine info



--
James Britt

"Judge a man by his questions, rather than his answers."
- Voltaire

Mike Johnson

4/15/2008 9:12:00 PM

0

Thank you Glen! This is exactly what I want. :)
--
Posted via http://www.ruby-....

Mike Johnson

4/15/2008 9:14:00 PM

0

Thanks all for helping me!
--
Posted via http://www.ruby-....

Robert Klemme

4/15/2008 9:38:00 PM

0

On 15.04.2008 23:03, Siep Korteling wrote:
> Glen Holcomb wrote:
>> On Tue, Apr 15, 2008 at 2:48 PM, Mike Johnson <freezingsmile@gmail.com>
>> wrote:
>>
>> Socket.gethostname
>>
>> --
>> "Hey brother Christian with your high and mighty errand, Your actions
>> speak
>> so loud, I can't hear a word you're saying."
>>
>> -Greg Graffin (Bad Religion)
>
> Did not know that one, thid works too:
>
> ENV["COMPUTERNAME"]

I would discourage using this approach as it is very error prone and not
portable.

Kind regards

robert