1753753 Members
5341 Online
108799 Solutions
New Discussion юеВ

HOSTNAME

 
SOLVED
Go to solution
tom quach_1
Super Advisor

HOSTNAME

Dear,

man hostname shown that /sbin/init.d/hostname
would set the hostname parameter on hpux 11.31
but when i do echo $ HOSTNAME
i get this error,
sh: HOSTNAME: Parameter not set
then i have to set hostname in /etc/profile
to get hostname from echo command.
does anyone know why.
Thanks in advance.
Tom
5 REPLIES 5
Tim Nelson
Honored Contributor
Solution

Re: HOSTNAME

HOSTNAME is just a shell variable.

If you wish it set for everyone's shell then you put it in /etc/profile.

e.g.

export HOSTNAME=`hostname`

James R. Ferguson
Acclaimed Contributor

Re: HOSTNAME

Hi Tom:

The 'HOSTNAME' variable is defined and editted in '/etc/rc.config.d/netconf'. It is established in '/sbin/init.d/hostname'.

If you want to use it in a script, reference it as:

# echo $(hostname)

Or:

# ME=$(hostname); echo "I am at '${ME}'"

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: HOSTNAME

In the /sbin/init.d/hostname script, you won't see HOSTNAME= anywhere in the script. It is set in the startup script configuration file located in /etc/rc.config.d/netconf. However, this variable is only used during startup.

If you really need HOSTNAME set, do it in /etc/profile:

export HOSTNAME=$(hostname)


Bill Hassell, sysadmin
Jeeshan
Honored Contributor

Re: HOSTNAME

check you have hostname

#hostname

if not set then run the command
#set_parms host_name


otherwise follow the instruction listed above.
a warrior never quits
tom quach_1
Super Advisor

Re: HOSTNAME

Thank you all for your helps.
Regards,