サブプロセスでこのコマンドを実行するにはどうすればよいですか?Python - サブプロセス - WindowsでPipedコマンドを呼び出す方法
私が試した:
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()
を得たが、私は気づいた
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
もの:
-
を
- 窓 コンソール上でコマンドを実行すると正常に動作します。
- もし私が削除したら ECHO bosco |上記のpopen呼び出しを 上手く実行します。だから私は この問題はエコーまたは と関連していると思う|。
はフルラインが実際に働くことをしていますか? WindowsErrorは、問題はPythonコードではなく、実際に実行されるコマンドであることを示しています。 –
はい、WindowsのDOSコンソールから実行されます。 – Greg