LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 08-26-2013, 05:38 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 507

Rep: Reputation: 31
HOSTNAME = hostname -> HOSTNAME: command not found ?


My script looks as follow:

Code:
#!/bin/sh

echo hello world

HOSTNAME = hostname

echo $HOSTNAME
As I run it I got error as follow:
Code:
./test.sh: line 5: HOSTNAME: command not found
What could be the problem?
 
Old 08-26-2013, 05:57 AM   #2
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 507

Original Poster
Rep: Reputation: 31
The problem is solved. I have to take out the space as follow:

Code:
#!/bin/sh

echo hello world

HOSTNAME=hostname

echo $HOSTNAME
 
Old 08-26-2013, 09:25 PM   #3
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 636

Rep: Reputation: 68
Quote:
HOSTNAME=hostname

echo $HOSTNAME

so why this much hasle... ?

when you can do it like this, in one single line:

Code:
echo $HOSTNAME   #this will give the same output as $HOSTNAME variable is already been setup for hostname command. 
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
clients CAN resolve hostname of server w/nslookup, but CANNOT access by hostname WTF? psycroptic Linux - Networking 9 11-10-2012 12:24 PM
https://hostname:1800/ or any hostname:port/ is blocked by smoothwall edgarhmg Linux - Security 3 02-23-2011 08:39 PM
Changed hostname during install, now CUPS has wrong hostname on web interface slinx Linux - Software 1 08-07-2009 09:01 PM
after hostname change, syslogd still output previous hostname to messages file tiger2000 Linux - General 3 07-22-2009 10:36 PM
hostname command vs. $HOSTNAME env. variable Silly22 Linux - Networking 2 03-29-2002 06:01 PM


All times are GMT -5. The time now is 12:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration