python中stdin.write"/>
python中stdin.write
我注意到两种方法的两种不同的行为应该导致相同的结果。
目标-使用子过程模块执行外部程序,发送一些数据并读取结果。
外部程序是PLINK,平台是WindowsXP,Python版本3.3。
主要思想
execution=["C:\\Pr..\\...\\plink.exe","-l", username,"-pw","***", IP]
a=subprocess.Popen(execution, bufsize=0, stdout=PIPE, stdin=PIPE, stderr=STDOUT, shell=False)
con=a.stdout.readline()
if (con.decode("utf-8").count("FATAL ERROR: Network error: Connection timed out")==0):
a.stdin.write(b"con rout 1
")
print(a.stdout.readline().decode("utf-8"))
a.stdin.write(b"infodf
")
print(a.stdout.readline().decode("utf-8"))
else:
print("ERROR")
a.kill()
到现在为止还挺好。
现在,我希望能够执行一个循环(每次写入子进程的stdin之后),该循环一直等到子进程的stdout的EOF结束后,打印出来,然后再执行另一个
更多推荐
python中stdin.write
发布评论