[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFE: hostname -s
Re: RFE: hostname -s
Wed, 27 Aug 2003 20:47:22 -0600
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 16> hostname -s
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
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/\..*//')
- RFE: hostname -s, David Kaelbling, 2003/08/27
- Re: RFE: hostname -s,
Bob Proulx <=