I am executing following bash script:
MACHINE=`cat ~/mach`
SSH_CMD="ssh -v root@$MACHINE -t 'echo foo'"
echo $SSH_CMD
$SSH_CMD
I am getting echo foo: command not found when I execute a script containing above. However, if I a copy and paste the echo-ed SSH_CMD and manually run it from command line, I am able to print foo on the console. What’s different and how can I workaround it?
I was expecting both to have same behavior since they look exactly same.
New contributor
p k is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.