[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01691] Re: gethostbyname?

From: ts <decoux@...>
Date: 2000-03-02 17:06:12 UTC
List: ruby-talk #1691
>>>>> "H" == Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:

H> That works, but I need the other methods to work because I 
H> cannot get an IP address easily with backticks.  I need the
H> IP address to mess about with sockets from what I can see.
H> Ok, I could call nslookup and munge the output, but it will be 
H> less efficient, and these other things ought to work.

 I've not understood, sorry. Your example don't work just because there is
 a \n at the end of thishost. If you remove it you can have your IP address

pigeon% cat b.rb
#!/usr/bin/ruby
ENV['PATH'] = "/usr/ucb:/bin"
require "socket"
print "PATH #{ENV['PATH']} \n"
thishost = `hostname`.chomp
print "this host is #{thishost}\n"
$, = " "
address = TCPSocket.gethostbyname(thishost)
print "this host has address #{address}\n"
address = TCPSocket.getaddress(thishost)
print "this host has address #{address}\n"
 
pigeon% b.rb
PATH /usr/ucb:/bin 
this host is pigeon
this host has address pigeon.moulon.inra.fr pigeon 2 138.102.114.46
this host has address 138.102.114.46
pigeon% 


Guy Decoux

In This Thread

Prev Next