On 2007-10-07 11:49:05 -0500, Dave Rolsky wrote:
> I've written code to get the fqdn from just the hostname that works
> provided is working in a sane way:
>
> sub fqdn {
> my $local = hostname();
>
> return $local unless _is_short($local);
>
> return ( gethostbyname($local) )[0] || $local;
> }
[...]
> I don't know if this is more or less portable than just calling "hostname
> --fqdn", but it works on Linux (heh ;)
It works on your particular Linux distribution. On some distributions it
might return the short name or even "localhost", depending on the
contents of /etc/hosts, /etc/nsswitch.conf and other factors.
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | [EMAIL PROTECTED] |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
signature.asc
Description: Digital signature
