하위 프로세스에서이 명령을 어떻게 실행합니까?Python - Subprocess - 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 보스코 | 부분, 위의 popen 호출 잘 실행됩니다. 그래서 나는 이 문제는 echo 또는 와 관련이 있다고 생각합니다.
전체 라인이 실제로 작동합니까 것을
이것은 당신이 본 오류와 함께 실패? WindowsError는 문제가 파이썬 코드가 아니라 실제 명령이 실행될 것을 제안합니다. –
예. Windows 콘솔에서 실행됩니다. – Greg