title: Unix: Using expect doesn't preserve the stderr
body: <p>I am performing the follwing line from a unix server:</p>
  
  <pre><code>expect -c 'spawn ssh otherHost chown -R user:group /usr ; expect password: ; send 123456\n ; interact ;'
  </code></pre>
  
  <p>I am getting return value 0, an empty stderr and a stdout that says <code>/usr/... Not owner, /usr/... Not Owner ..</code>.</p>
  
  <p>If I perform the command line <code>ssh otherHost chown -R user:group /usr</code> alone, then this message is returned appropriately with return value !=0 and the error messages in the error stream.</p>
  
  <p>I need to know programmatically if there was an error, and expect (which I need to avoid passing password) doesn't allow me. (A good idea would be to use expect to create sshkeys, and then ssh normally to servers - but I need the servers to have passwords between them).</p>
  
  <p>Anyway, how can I find out an error occured while using expect?</p>