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

  • It would be useful to know what is the output of hostname? – Julie Pelletier Jun 25 '16 at 1:30
  • @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 Jun 25 '16 at 1:37

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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