title: Issues with subprocess.Popen() replacing os.system()
body: <p>I am trying to generate a set of files through a python script on a 48-core cluster which actually has a master-and 3 slave machines. I need to generate a set of files, run some scripts on them, collect results and then delete them. I again repeat the process- regenerate files, execute, delete etc.,
  When I delete and regenerate files with the same name, I see that the slave machine complains that it cannot find the files.
  I am running python script through <code>os.system()</code></p>
  
  <p>I learnt from <a href="https://stackoverflow.com/questions/4837127/how-can-i-delay-execution-until-after-os-system-finishes">this post</a> that it is better to use <code>subprocess.Popen()</code> rather than <code>os.system</code> so that it actually waits for my script to generate my files, before proceeding with the execution. I could use <code>os.system("pause")</code> or <code>time.sleep(whatever)</code> for waiting, but I want to convert my os.systems to subprocess.popens or subprocess.calls and I am stuck here.</p>
  
  <p>I ran through the python documentation and tried out <code>subprocess.Popen('ls')</code>, but I am not able to get a simple thing like <code>subprocess.Popen('cd /whatever_directory')</code> working.</p>
  
  <p>It might sound silly but how do I execute such a simple command like <code>cd</code> through <code>subprocess</code> rather than <code>os.system('cd')</code>?</p>
  
  <p>Then, I actually want to convert the following into subprocess. How do I do it? </p>
  
  <pre><code>import os,optparse
  from optparse import OptionParser
  
  parser.add_option("-m", "--mod",dest='module', help='Enter the entity name')
  parser.add_option("-f", "--folder", dest="path",help="Enter the path")
  
  module=options.module
  path=options.path
  
  os.system('python %s/python_repeat_deckgen_remote.py -m %s' %(path,module))
  </code></pre>
  
  <p>I just replaced os.system with subprocess.Popen.
  But it gave me a lot of complaints:</p>
  
  <pre><code>File "/usr/lib64/python2.6/subprocess.py", line 633, in __init__
      errread, errwrite)
    File "/usr/lib64/python2.6/subprocess.py", line 1139, in _execute_child
      raise child_exception
  OSError: [Errno 2] No such file or directory
  </code></pre>