I have noticed that some systems don't support "hostname".
Try this, HOSTNAME=`uname -n`. (use the back tic, next to the 1 key. This will give the hostname as well.
Also, it is good programming to use ALL CAPS for variable names. This will prevent accidental execution of system commands.
Enjoy!