critical impact:
hostname - option unavailable (CrUn373)
Problem description
The -s option for the hostname command exists on Tru64 UNIX but not on HP-UX.
The hostname command sets or displays the name of the current host system. On Tru64 UNIX, the -s option displays the short form of the host name.
The -s option is not available on HP-UX. If a privileged user executes hostname -s on HP-UX, then hostname is set to -s. That setting lasts until the system is rebooted. If a nonprivileged user executes it, the command fails with the following error:
You must be superuser to set the hostname
Identifiers
 hostname:-s |
|
|
|
See also
Solution description
Extract the short form of the host name yourself. The examples show several ways of doing this.
Be sure to check shell initialization files like .profile and .login for hostname -s -- especially the ones for root -- because they often use the command to set the shell prompt. New behavior
# extract the short form of the host name in any shell
hostname | awk -F . '{print $1}'
hostname | cut -f 1 -d .
hostname | sed 's/\..*//'
# set a short host name prompt in the Korn and POSIX shells
host="$(hostname)"
PS1="${host%%.*}> "
# bash
PS1="\h> "
# tcsh
set prompt="%m> "
See also
Problem summary
| classifications |
source types |
OS release |
severity |
type |
| CMD |
Make, Script |
any HP-UX 11i version |
critical |
unavailable |
|