Python - Subprocess - How to call a Piped command in Windows? -


I have run this command with subprocess

I tried:

  proc = subprocess.Popen ('' 'echo bosco |' C: \ Program Files \ GNU \ GnuPG \ gpg.exe "--batch --passphrase-fd 0 --output" c: \ docume ~ 1 \ Same locals ~ 1 \ temporary \ tmptlbxka.txt test.txt.gpg "" --decrypt "'' ', stdin = subprocess.ipip, stdout = subprocess.ipip, stderr = subprocess.STDOUT,) stdout_value, stderr_value = Proc .communicate ()  

but found:

  Traceback (last most recent call): ... file "C: \ Python24 \ lib \ subprocess .py ", line 542, __init__ errread, errrite) file" C: \ Python24 \ lib \ sub   

        Li> Running commands on the Windows console works fine
      1. If I remove the ECHO Bosco part, run it right popen up the run. So I think this problem is related to echo.

First of all, you do not really need a pipe; You are just sending input you can use for it.

Second, do not specify the command as a string; As soon as the file names are included with the blank, this is a mess.

Thirdly, if you really wanted to execute a pipe command, then call the bus. On Windows, I believe this is the CMD / C program name logic. Further Content .

Finally, a single back slash can be dangerous: " is '\\ p' , but '\ n ' is a new line or use a specified Python out of Python, or just a forward slash.

  proc = subprocess.Popen (['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.ipip, stdout = Subprocess.PIPE, stderr = subprocess.STDOUT,) stdout_value, stderr_value = proc.communicate ('Bosco')  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -