I am trying to run a script on a remote system using ssh, when i run the command on the terminal it executes fine but when i embed the command in a shell script it returns an error.
cmd="ssh root@IP \"python /pathtoscript\"" `$cmd` > log.log
for the above command i tried the following suggestions from stack exchange:
cmd="ssh root@IP \"bash -c 'python /pathtoscript'" cmd="ssh root@IP '/user/bin/python /pathtoscript'"
ssh root@IP "ls -1v /path"
Note: All these commands work on the terminal.
Edit: If i run the command on the terminal it executes fine and displays the output Now if the same command is added to a script (.sh), I see the following error: bash: ssh root@IP 'python /pathtoscript' : No such file or directory