title: Capture output of bash script over ssh within script
body: <p>I am aware of this discussion:
  <a href="https://stackoverflow.com/questions/2374276/running-a-bash-script-over-ssh">Running A Bash Script Over SSH</a></p>
  
  <p>However, I have a somewhat varied take on it - and it's got me stumped.</p>
  
  <p>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.</p>
  
  <p>My problem comes to substituting variables into the ssh commands (such an elementary subject) but I'm missing something here. </p>
  
  <p>Here's the issue:</p>
  
  <pre><code>#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
  </code></pre>
  
  <p>No matter how many ways I use single or double quotes, I only get back something along the lines of:</p>
  
  <blockquote>
    <p>bash ls -lt command not found</p>
  </blockquote>