title: Using python to run another program?
body: <p>I have a program that I run from the command line that looks like this:</p>
  
  <p><code>$ program a.txt b.txt</code></p>
  
  <p>The program requires two text files as arguments. I am trying to write a Python 3.2 script to run the above program. How can I do this? Currently, I am trying to use the <code>subprocess</code> module like this:</p>
  
  <pre><code>import subprocess
  
  with open("a.txt", mode="r") as file_1:
      with open("b.txt", mode="r") as file_2:
          cmd = ['/Users/me/src/program', file_1, file_2]
          process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
          for line in process.stdout:
              print(line)
  </code></pre>
  
  <p>I read <a href="https://stackoverflow.com/questions/89228/how-to-call-external-command-in-python">this post</a> and the post <a href="https://stackoverflow.com/questions/325463/launch-a-shell-command-with-in-a-python-script-wait-for-the-termination-and-retu">here</a>, which seem to describe similar solutions to my problem. Unfortunately, after reading these posts, I still can't seem to make my Python code run my program.</p>
  
  <p>Can anyone help? Thanks in advance!</p>