双字符同时使用 pexpect 进行交互()
Double Characters while do interact() using pexpect
我正在使用 Pexpect 进行测试。
w1 = pexpect.spawn('telnet XXXX')
# or
w1 = pxssh.pxssh()
# both with
w1.logfile_read =sys.stdout
而且 运行 很好;但是,如果我在某个时候这样做:
w1.interact()
然后尝试在屏幕上写一些东西我得到双字符。
例如,如果我输入:rmdir
它将是 rrmmddiirr
.
我怎样才能拥有一个角色?
interact()
会为您处理回显,因此您需要这样做:
w1.logfile_read = None
w1.interact()
根据预期doc:
interact(escape_character='\x1d', input_filter=None, output_filter=None)
This gives control of the child process to the interactive user (the human at the keyboard). Keystrokes are sent to the child process, and the stdout and stderr output of the child process is printed. This simply echos the child stdout and child stderr to the real stdout and it echos the real stdin to the child stdin. [...]
If a logfile is specified, then the data sent and received from the child process in interact mode is duplicated to the given log.
我正在使用 Pexpect 进行测试。
w1 = pexpect.spawn('telnet XXXX')
# or
w1 = pxssh.pxssh()
# both with
w1.logfile_read =sys.stdout
而且 运行 很好;但是,如果我在某个时候这样做:
w1.interact()
然后尝试在屏幕上写一些东西我得到双字符。
例如,如果我输入:rmdir
它将是 rrmmddiirr
.
我怎样才能拥有一个角色?
interact()
会为您处理回显,因此您需要这样做:
w1.logfile_read = None
w1.interact()
根据预期doc:
interact(escape_character='\x1d', input_filter=None, output_filter=None)
This gives control of the child process to the interactive user (the human at the keyboard). Keystrokes are sent to the child process, and the stdout and stderr output of the child process is printed. This simply echos the child stdout and child stderr to the real stdout and it echos the real stdin to the child stdin. [...]
If a logfile is specified, then the data sent and received from the child process in interact mode is duplicated to the given log.