title: Python: Failing to open a file using os.system()
body: <p>I'm coding a Python script which is using the application <a href="http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/" rel="nofollow">pdftk</a> a few times to perform some operations.</p>
  
  <p>For example, I can use pdftk in the windows command line shell to merge two pdf files like this:</p>
  
  <pre><code>pdftk 1.pdf 2.pdf cat output result.pdf
  </code></pre>
  
  <p>I would like to perform the above operation in the middle of my Python script. Here's how I tried doing it:</p>
  
  <pre><code>os.system('pdftk 1.pdf 2.pdf cat output result.pdf')
  </code></pre>
  
  <p>The above pdftk command works perfectly in the Windows shell. However, it fails to open the input files (1.pdf and 2.pdf) when I'm trying to execute it using Python's <code>os.system()</code>. Here's the error message I get from pdftk when trying to execute the command using Python's <code>os.system()</code>:</p>
  
  <blockquote>
    <p>Error: Failed to open PDF file: 
       1.pdf</p>
    
    <p>Error: Failed to open PDF file: 
       2.pdf</p>
  </blockquote>
  
  <p>Why does it happen? How can I fix it?</p>
  
  <p>Please note: I know there are better ways to merge pdf files with Python. My question isn't about merging pdf files. That was just a toy example. What I'm trying to achieve is an ability to execute pdftk and other command line applications using Python. </p>