develooper Front page | perl.perl5.porters | Postings from February 2000

Re: fixing Sys::Hostname

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
February 8, 2000 07:48
Subject:
Re: fixing Sys::Hostname
Message ID:
200002081547.PAA26816@tiuk.ti.com
Tom Christiansen <tchrist@chthon.perl.com> writes:
>>  ($host) = gethostbyname('localhost');
>
>>Sadly most UNIX boxes don't add a sane alias to their /etc/hosts file
>>so that trick is not portable.
>
>    % grep localhost /etc/hosts
>    127.0.0.1	localhost	

Which is exactly my point ;-)  there is no alias there, just the one name
and that makes 'localhost' the official name of the address.

If I do gethostbyname('localhost') on such a machine I get 'localhost'
back. But I would "like" to get back "pluto" or "pluto.tiuk.ti.com"

Thus my entry "should" be :

127.0.0.1	pluto.tiuk.ti.com pluto localhost	

and yours "should" be : 

127.0.0.1	chthon.perl.com chthon localhost	


-- 
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About