title: Python - Subprocess - How to call a Piped command in Windows?
body: <p>How do I run this command with subprocess?</p>
  
  <p>I tried:</p>
  
  <pre><code>proc = subprocess.Popen(
      '''ECHO bosco|"C:\Program Files\GNU\GnuPG\gpg.exe" --batch --passphrase-fd 0 --output "c:\docume~1\usi\locals~1\temp\tmptlbxka.txt" --decrypt "test.txt.gpg"''',
      stdin=subprocess.PIPE,
      stdout=subprocess.PIPE,
     stderr=subprocess.STDOUT,
  )
  stdout_value, stderr_value = proc.communicate()
  </code></pre>
  
  <p>but got:</p>
  
  <pre><code>Traceback (most recent call last):
  ...
    File "C:\Python24\lib\subprocess.py", line 542, in __init__
      errread, errwrite)
    File "C:\Python24\lib\subprocess.py", line 706, in _execute_child
      startupinfo)
  WindowsError: [Errno 2] The system cannot find the file specified
  </code></pre>
  
  <p>Things I've noticed:</p>
  
  <ol>
  <li>Running the command on the windows
  console works fine. </li>
  <li>If I remove the
  ECHO bosco| part, it runs fine the
  the popen call above.  So I think
  this problem is related to echo or
  |.</li>
  </ol>