get host name

M

Mark Volkmann

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.

--=20
R. Mark Volkmann
Partner, Object Computing, Inc.
 
D

Daniel Berger

Mark said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top