i am using subprocess to call a external program plink.exe to login to a server, but when i call communicate to read the output, it blocking. the code is below:
import subprocess
process = subprocess.Popen('plink.exe [email protected] -pw 123456'.split(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print process.communicate() #block here
i know the block is because the plink.exe it still running. but i need to read the output before the subprocess terminal. is there anyway to do it? thanks in advance.