$HOSTNAME empty while invoking script using SSH

Hi,
I am unable to get $HOSTNAME value in a remote script when executed through SSH. Also the scripts hangs and doesnt return to the calling environment.

For instance

command - 
ssh user1@box2 "cd /var/home/bin ; ./generateScript.sh"

Can any one plese throw light on the issue and also if there is a miss in environment setup or something.

P.S. - When i run the same script on different set of boxes the script works fine.

http://www.unix.com/shell-programming-scripting/114487-ssh-remote-commands-echo-oh-my.html

I didnt get the link you provided... can you explain in brief what can be the workaround?

ssh user1@box2  "echo \$HOSTNAME"

check whether you can able to get the box2 hostname. If yes, then you can pass it as argument to your script.

I tried it on the box but it still results in empty HOSTNAME Value

i just got an answer for your question.

check out here...

linux - Why does an SSH remote command get fewer environment variables then when run manually? - Stack Overflow