title: How to run Multiple external commands from Python Script
body: <p>I have a requirement where I have to run these few commands in the terminal using a python script.The requirement is as such:</p>
  
  <p>ssh abc.xyz.com</p>
  
  <p>After ssh to that machine, ssh to the environment</p>
  
  <p>ssh qa</p>
  
  <p>and then run few commands in the environment</p>
  
  <p>I have tried achieving this using os.system() and using subprocess.call() but no luck.</p>
  
  <p>Specifically, I tried doing this :</p>
  
  <pre><code>import subprocess
  from time import sleep
  subprocess.call("ssh abc.def.com", shell=True)
  subprocess.call("python", shell=True)
  sleep(0.3)
  subprocess.call("ssh qa", shell=True)
  </code></pre>