title: Python Subprocess CalledProcessError when calling remote shutdown command exit status 6
body: <p>My code runs a linux command to send a shutdown signal to a remote linux machine. Running the command on the linux terminal succeeds in shutting down the remote machine but using Python <code>subprocess</code> to call the command results in an error.</p>
  
  <p>Code:</p>
  
  <pre><code>import subprocess
  res = subprocess.check_call("sshpass -pPassword ssh root@192.168.1.2 sudo shutdown now", shell=True)
  </code></pre>
  
  <p>Result from Python 2.7:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 'sshpass -pPassword ssh root@192.168.1.2 sudo shutdown now' returned non-zero exit status 6
  </code></pre>
  
  <p>Result from Python 3:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 'sshpass -pPassword ssh root@192.168.1.2 sudo shutdown now' returned non-zero exit status 6
  </code></pre>
  
  <p>With the target machine remaining unchanged.</p>
  
  <p>Running <code>sshpass -pPassword ssh root@192.168.1.2 sudo shutdown now</code> alone on the command line succeeds and returns with <code>Connection to 192.168.1.2 closed.</code></p>
  
  <p>This seems like it could be a <code>subprocess</code> + <code>sshpass</code> issue.</p>
  
  <p>What am I missing?</p>
  
  <p><strong>Update</strong>:
  Haven't fixed the above problem but for some reason using <code>subprocess.check_output</code> instead of <code>check_call</code> executes the command successfully albeit returning <code>non-zero exit status 255</code></p>