How to get the Unix machine name in a shell script?

Hi,
I have shell (tcsh) script and I would like to get the name of the machine that I run this script and assign it to a variable.

How can I do it?

Thanks,
TolgarAsked:
Who is Participating?
 
TintinConnect With a Mentor Commented:
set variable=`uname -n`

Open in new window

0
 
PapertripConnect With a Mentor Commented:
uname -n

Open in new window


You can also do 'hostname', but that is potentially dangerous since anything you accidentally put after 'hostname' will change the hostname of your machine.

Real world example:
Old Solaris machine running some productions DB's
Instead of 'sudo -s' they ran messed up and typed 'hostname -s' and hosed the system ;)
0
 
AnacreoCommented:
It should already be in the variables...

${HOST}
0
All Courses

From novice to tech pro — start learning today.