我正在使用paramiko来ssh到远程机器,目前这一步似乎运行良好。
现在从远程机器开始更深入的操作,使用以下命令可以提供正确的处理方式以便使用
然后我可以通过按“e”键退出(无需按“enter”键立即退出)。但是当我尝试在我的脚本中这样做时,使用`stdin.write('^]e')`,`stdin.write('\^]e')`,`stdin.write('\c]e')`,`stdin.write('\M-\C-]e')`等方式,始终只能在stdout.read()中看到我的脚本已经逐字输入这些字符。在“]”和“e”之间放置一个小的`time.sleep(0.1)`似乎没有帮助。如何以编程方式输入该转义序列?
现在从远程机器开始更深入的操作,使用以下命令可以提供正确的处理方式以便使用
stdin.write
进行通信:
stdin, stdout, stderr = client.exec_command('telnet localhost %d'%port)
Escape character is '^]'.
我可以在键盘上使用Ctrl+]
,然后弹出一个小菜单。Console escape. Commands are:
l go to line mode
c go to character mode
z suspend telnet
e exit telnet
然后我可以通过按“e”键退出(无需按“enter”键立即退出)。但是当我尝试在我的脚本中这样做时,使用`stdin.write('^]e')`,`stdin.write('\^]e')`,`stdin.write('\c]e')`,`stdin.write('\M-\C-]e')`等方式,始终只能在stdout.read()中看到我的脚本已经逐字输入这些字符。在“]”和“e”之间放置一个小的`time.sleep(0.1)`似乎没有帮助。如何以编程方式输入该转义序列?