[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFE: hostname -s

From: Bob Proulx
Subject: Re: RFE: hostname -s
Date: Wed, 27 Aug 2003 20:47:22 -0600
User-agent: Mutt/1.3.28i

David Kaelbling wrote:
> On IRIX the /usr/bsd/hostname command supports a "-s" option that makes
> it return the simple (no domain) version of the host name:
>       orchietta 15> hostname
>       orchietta.hudson.sgi.com
>       orchietta 16> hostname -s
>       orchietta

FreeBSD and I presume other BSD flavors also support that option.
Also both Debian and Red Hat ship Peter Tobias' version of hostname
from the net-tools package with this and other options.  So there is
momentum in that direction.

The proclivity of people to this option depends upon whether you like
the convention of fully qualified domain names as hostnames or the
convention to use only the short name.  I personally prefer the FQDN
for the hostname.  That works with the widest variety of software and
seems the most natural IMNHO.  But othere like it the other way.

Hmm...  Would 'hostname' be one of the utilities that makes the most
sense in the new GNU sysutils that Jeff Bailey is working on?

> It would be nice if the GNU sh-utils hostname also dealt with this
> option, as currently some scripts that are sloppy with the PATH settings
> break with messages like this:
>       hostname: cannot set hostname to `-s': Operation not permitted
> Naturally such scripts are wrong, but still...

Worse are the installation scripts to be run by root which use the
'-f' GNU option extension to ensure a fully qualifed domain name.  I
can't tell you the number of times I have changed the hostname to "-f"
on HP-UX systems, which do not support that option, when running
installation scripts as root.  Surprisingly I have never run into an
installation script which set the hostname to "-s".  :-)

I have to put on my portability hat.  Stand back!  Closed driver on a
professional track.

Let me recommend that POSIX portable scripts use a construct similar
to the following to avoid those problems.


Or perhaps if it is needed all at one pass.

    HOSTNAME=$(hostname | sed 's/\..*//')


reply via email to

[Prev in Thread] Current Thread [Next in Thread]