>>>>> "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