Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

enter image description here

I entered same command with a variable host. During 2nd time I entered blank space between host,= and $. Why it was trying to connect to a server ? Also, when I write like $(host name), I am getting error Host = not found: 3(NXDOMAIN) centos

share|improve this question
    
It would be useful to know what is the output of hostname? – Julie Pelletier yesterday
    
@JuliePelletier Output is centos. For first time it gives output correctly when entered without space. But during second time as you can see it tries to connect to a server and then prints the output centos. – abc yesterday
up vote 5 down vote accepted

There must not be any spaces between a variable name and the equation mark. When there are spaces, the variable name is interpreted as a command, in this case the command host is run with parameters = and the host name.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.