Executing multiple commands using Popen.stdin

前端 未结 4 1405
醉酒成梦
醉酒成梦 2021-02-07 04:58

I\'d like to execute multiple commands in a standalone application launched from a python script, using pipes. The only way I could reliably pass the commands to the stdin of th

4条回答
  •  渐次进展
    2021-02-07 05:21

    If I understand your problem correctly, you want to interact (i.e. send commands and read the responses) with a console application.

    If so, you may want to check an Expect-like library, like pexpect for Python: http://pexpect.sourceforge.net

    It will make your life easier, because it will take care of synchronization, the problem that ddaa also describes. See also: http://www.noah.org/wiki/Pexpect#Q:_Why_not_just_use_a_pipe_.28popen.28.29.29.3F

提交回复
热议问题