help on environment variable

what is the environment variable used for getting the <machine name> .

hello $LOGNAME,welcome to <??>

I want to print the machine name in the place of <??>

Please help.

on HP-UX 11.0 you have $HOSTNAME by default..

you can do like this in the script if its not in the HOSTNAME variable...

the solution below is better because it will work on almost all unix systems...

MY_HOSTNAME=`hostname`
echo $MY_HOSTNAME

/Peter

You may want to also check out the man page for uname.

When I try Peter's script, I get "goliath.site.net".

uname -n displays just "goliath", so it depends how much you want displayed..

oombera:
strange that you get the FQDN?
What platform are you running?

it can be that the machine has the FQDN as hostname and thats wrong? anyone??

but whatever.. just replace hostname with uname -n
:slight_smile:

/Peter

im running suse linux 8.1 and uname -n gives me the same out put. what does it give you?

Maybe the FQDN option is only available for linux? We use SCO Unix and that option doesn't exist for the hostname command..

For me, your script and uname -n actually give two slightly different outputs..

However,
MY_HOSTNAME=`hostname -s`
echo $MY_HOSTNAME
displays the same output as uname -n

thank you all for ur support.

I got it through. The problem I had posted.

expect the same kind of support from all of you.

Thanks & Regards.
Mehul Doshi