使用subprocess.call时,输出是预期的.
result = subprocess.call([securefx, '/NoPrompt', '/Q', '/RetryCount', retries,
'/RetryDelay', '1', '/Log', sfxLogFile, '/List', '/S', session])
Run Code Online (Sandbox Code Playgroud)
打印结果将输出-533428或0
但是当我跑步的时候
args = [securefx, '/NoPrompt', '/Q', '/RetryCount', retries, '/RetryDelay', '1',
'/Log', sfxLogFile, '/List', '/S', session]
process = subprocess.Popen(args, stdout=subprocess.PIPE)
result = process.communicate()[0]
Run Code Online (Sandbox Code Playgroud)
并打印结果,我得到空白或其他stderr ="无".
他们为什么不同?我正在尝试Popen即使调用正在工作的原因是因为:sfxcl.exe上的Python subprocess.call无法在Windows 2003任务调度程序中工作 < - 我想给它一个...
And*_*ark 10
subprocess.Popen返回一个Popen对象,您可以使用该对象与进程通信并获取输出,但是subprocess.call只返回进程的返回代码:
subprocess.call(*popenargs, **kwargs) Run command with arguments. Wait for command to complete, then return the returncode attribute.
因此subprocess.call基本上等同于以下代码,并且仅为方便起见而存在:
def call(*popenargs, **kwargs):
p = subprocess.Popen(*popenargs, **kwargs)
return p.wait()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4021 次 |
| 最近记录: |