[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

get host name

Mark Volkmann

7/17/2005 2:18:00 PM

How can I get the host name for the machine I'm running on from Ruby code?
I don't want to exec a Unix command to do this because I want it to
also work under Windows.
I want this for building a server URL that I'll be using with drb.
I don't want to hardcode a host name.

--
R. Mark Volkmann
Partner, Object Computing, Inc.


1 Answer

Daniel Berger

7/17/2005 2:21:00 PM

0

Mark Volkmann wrote:
> How can I get the host name for the machine I'm running on from Ruby code?
> I don't want to exec a Unix command to do this because I want it to
> also work under Windows.
> I want this for building a server URL that I'll be using with drb.
> I don't want to hardcode a host name.

require "socket"
puts Socket.gethostname

Regards,

Dan