Python - subprocess
, , check_call
check_output
, " stdout = PIPE stderr = PIPE ", :
1: script
proc = subprocess.Popen(["your_command", "parameter1", "paramter2"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
, .
EDIT: - , Python . , stdout stderr , communicate
2.
2:
stdout, sterr = proc.communicate()
return_code = proc.returncode
communicate
-:
- stdin (
input=
) - , (
timeout=
)
, Popen
communicate
.
Python, subprocess.run
, :
completed_process = subprocess.run(
['your_command', 'parameter'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
completed_process.returncode
completed_process.stdout
completed_process.stderr
completed_process.check_returncode()
check=True
run
.