I'm trying to echo multiline variable over ssh, but the second line gets executed as a command.
msg="Hello World; Hello World2"; echo $msg; ssh -q newhost "echo "$msg""
Output:
Hello World; Hello World2
Hello World
bash: Hello: command not found
I'm trying to echo multiline variable over ssh, but the second line gets executed as a command.
msg="Hello World; Hello World2"; echo $msg; ssh -q newhost "echo "$msg""
Output:
Hello World; Hello World2
Hello World
bash: Hello: command not found
Is there a reason it needs to be a multi-line variable? why not send two distinct messages?
msg="Hello World"; msg2="Hello World2"; echo $msg; ssh -q localhost "echo "$msg""$msg2""
works fine
echo -e will let you interpret escaped characters like \n which you should use instead of semicolon ;