2

I have this command succession:

echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567

and let's say it return a string like, for example "Hello...bla". On the 89.196.167.2 system, I have made a server that takes ssh commands, executes them, and returns the result to the client. That ssh program is running OK; it returns what I need, so that is not the problem.

I want to put this returned value, "Hello...bla", into a variable and use it. If I try this:

var=echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567;echo "$var"

it doesn't work. Bash returns this:

-bash: -ne: command not found

Can you please help me with a solution?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Andreea
  • 155

1 Answers1

3

Use backticks. i.e.:

var=`echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567`
Didi Kohen
  • 1,841