title: python subprocess - get exit status of command run on different machine using rsh
body: <p>I am trying to run some commands on some machine which I am connecting through the <code>rsh</code> command (can't use <code>ssh</code> for my case).</p>
  
  <p>Through <code>subprocess.check_call</code> function, I am executing the command and am expecting <code>check_call</code> to exit with exception when exit status of my "<code>cd /libs/</code> " command indicates failure.</p>
  
  <p>Below is the code I am trying out.</p>
  
  <pre><code>with open('logs.txt','w') as outstream:
      subprocess.check_call("rsh bldr 'cd /libs/' ", shell=True,stdout=outstream)
  </code></pre>
  
  <p>But here, <code>rsh</code> only returns its exit status and not the command it's executing.</p>
  
  <p>Because of which even in command failure case no error from <code>check_call</code> function, as it is getting <code>rsh</code> exit status which will be 0 always.</p>
  
  <p>So, how to get the exit status of the command here?</p>
  
  <p>Also, how can I make <code>check_call</code> fail based on my command exit status?</p>
  
  <p>Note: I am trying to change directory to /libs which doesn't exist. I am hoping for <code>check_call</code> to fail here and stop execution of script.</p>