title: Capturing SSH output as variable in bash script
body: <p>I've been struggling with this problem when writing a bash script.
  Basically, I want to measure the time of a program on a remote server, so I use the command:
  <code>/usr/bin/time -f %e sh -c "my command &gt; /dev/null 2&gt;&amp;1"</code> to execute the program.
  However, it appears that I cannot capture the output of my command (SSH) to a variable at all. In fact, the result (time) keeps getting printed out to stdout.</p>
  
  <p>The full code is:</p>
  
  <pre><code>respond=$(ssh ${fromNode} /usr/bin/time "-f" "%e" "'sh' '-c' 'virsh migrate --live ${VM} qemu+ssh://${toNode}/system --verbose &gt; /dev/null 2&gt;&amp;1'")
  </code></pre>
  
  <p>The value of respond is just empty, though the time is printed out to the standard output.</p>