I need to get the fully expanded hostname of the host that my Ruby script is running on. In Perl I've used Sys::Hostname::Long with good results. Google seems to suggest I should use Socket.hostname in ruby, but that's returning just the nodename, not the full hostname.
+1
A:
This seems to work:
hostname = Socket.gethostbyname(Socket.gethostname).first
dvorak
2008-09-30 02:43:19
Socket.gethostname doesn't necessarily return a FQDN.
dvorak
2009-12-04 00:41:51