LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 04:38 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
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, 04:57 AM   #2
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

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

Code:
#!/bin/sh

echo hello world

HOSTNAME=hostname

echo $HOSTNAME
 
1 members found this post helpful.
Old 08-26-2013, 08: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: 665

Rep: Reputation: Disabled
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



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 11:24 AM
https://hostname:1800/ or any hostname:port/ is blocked by smoothwall edgarhmg Linux - Security 3 02-23-2011 07:39 PM
Changed hostname during install, now CUPS has wrong hostname on web interface slinx Linux - Software 1 08-07-2009 08:01 PM
after hostname change, syslogd still output previous hostname to messages file tiger2000 Linux - General 3 07-22-2009 09:36 PM
hostname command vs. $HOSTNAME env. variable Silly22 Linux - Networking 2 03-29-2002 05:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:52 PM.

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
Open Source Consulting | Domain Registration