First of all, you really don't need a pipe; you just send input. You can use subprocess.communicate for this.
Secondly, do not specify the command as a string; this is randomly as soon as filenames with spaces are involved.
Thirdly, if you really want to execute a command with channels, just call the shell. On Windows, I find it cmd /c program name arguments | further stuff cmd /c program name arguments | further stuff .
Finally, one slash can be dangerous: "\p" is '\\p' , but '\n' is a new line. Use os.path.join () or os.sep or, if specified outside of python, just a 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.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, ) stdout_value, stderr_value = proc.communicate('bosco')
phihag
source share