When using subprocess.call, the output is what is expected.
result = subprocess.call([securefx, '/NoPrompt', '/Q', '/RetryCount', retries,
'/RetryDelay', '1', '/Log', sfxLogFile, '/List', '/S', session])
Printing the result will output something like
-533428 or 0
But when I run
args = [securefx, '/NoPrompt', '/Q', '/RetryCount', retries, '/RetryDelay', '1',
'/Log', sfxLogFile, '/List', '/S', session]
process = subprocess.Popen(args, stdout=subprocess.PIPE)
result = process.communicate()[0]
and print the result, I get blank or otherwise stderr = “None”.
Why are they different? The reason I’m trying Popen even though call is working is because of this: Python subprocess.call on sfxcl.exe not working from Windows 2003 Task Scheduler <- thought I’d give it a go…
subprocess.Popenreturns a Popen object, which you can use to communicate with the process and get output, howeversubprocess.callwill only return the return code of the process:So
subprocess.callis basically equivalent to the following code, and only exists for convenience: