Front page | perl.perl5.porters |
Postings from February 2000
Re: fixing Sys::Hostname
From:
Nick Ing-Simmons
Date:
February 8, 2000 07:59
Subject:
Re: fixing Sys::Hostname
Message ID:
200002081558.PAA27173@tiuk.ti.com
Andy Dougherty <doughera@lafayette.edu> writes:
>
>/* HAS_GETHOSTNAME:
> * This symbol, if defined, indicates that the C program may use the
> * gethostname() routine to derive the host name. See also HAS_UNAME
> * and PHOSTNAME.
> */
>/* HAS_UNAME:
> * This symbol, if defined, indicates that the C program may use the
> * uname() routine to derive the host name. See also HAS_GETHOSTNAME
> * and PHOSTNAME.
> */
>
>The metaconfig unit anticipates the possibility that gethostname() will be
>there but inappropriate to use, and allows for other mechanisms to get the
>host name.
My Solaris2 Config.pm does not have HAS_GETHOSTNAME set (it has HAS_UNAME)
but Solaris does have gethostname(), so some kind of preferencing
has already happened. This is okay though as (at least on Solaris 2.7)
the size of the field in uname is big enough.
>Probably the most useful one for non-Unix systems is to run
>popen($aphostname, "r") to determine the hostname.
Unlikely IMHO - it is probably better for them to #define gethostname()
or uname() to something that finds the information some other way.
For example Win32's equivalent is a registry variable - which is
"easy" to get at from C but for which there is not a standard command
line utility to access.
--
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.