I am aware of this discussion: Running A Bash Script Over SSH
However, I have a somewhat varied take on it - and it's got me stumped.
I have an ssh alias in my ~/.ssh/config called remServer to which I can ssh just fine. I'd like to run some remote commands on that server and deal with the output on the local server.
My problem comes to substituting variables into the ssh commands (such an elementary subject) but I'm missing something here.
Here's the issue:
#this works
op="ls"
cmd="ssh remServer '$op'"
res=`$cmd`
echo $res
#this doesn't
op="ls -lt"
cmd="ssh remServer '$op'"
res=`$cmd`
echo $res
No matter how many ways I use single or double quotes, I only get back something along the lines of:
bash ls -lt command not found
ssh remServer 'ls'interactively? Could you check in the shell configuration files (.bashrc and so on) on the remote system to see if there is an alias for thelscommand?