title: run os.system command as subprocess python
body: <p>I want to run the following <strong>os.system</strong> command as a subprocess in order to know its pid since I want to be able to perform a </p>
  
  <pre><code>proc.terminate()
  </code></pre>
  
  <p>Bellow is the <code>os.system()</code> Command that works. Note that the bellow command already opens a subshell since thats what the <code>setview</code> is doing, and then executes a python script inside that subshell and then exits that subshell.</p>
  
  <pre><code>   os.system("/usr/atria/bin/cleartool setview -exec '/usr/bin/python /home/testUser/Development/Scripts/setDoneFlag_Count_Lines.py' testUser__project_5_0_myProject_001")
  </code></pre>
  
  <p>I tried </p>
  
  <pre><code>import subprocess
  cmd = "/usr/atria/bin/cleartool setview -exec '/usr/bin/python /home/testUser/Development/Scripts/setDoneFlag_Count_Lines.py' testUser__project_5_0_myProject_001"
  p=subprocess.Popen(cmd.split(), shell=True)
  </code></pre>
  
  <p>Taken from this stackoverflow thread: <a href="https://stackoverflow.com/questions/20218570/how-to-determine-pid-of-process-started-via-os-system">How to determine pid of process started via os.system</a>
   But it only executes the first <code>/usr/atria/bin/cleartool</code> and not the other commands. Anyone knows how to write a subshell that is equivalent to my os.system call?</p>
  
  <p>Thanks in advance.</p>