如何在不退出telnet的情况下在“ child.interact()”之后进行“ child.sendline()”?

#! /usr/bin/python
import pexpect
import sys

host = sys.argv[1]
port = sys.argv[2]
command = sys.argv[3]
console = 'console'
child = pexpect.spawn("telnet %s %s" %(host,port),logfile=sys.stdout)
index = child.expect([console,pexpect.EOF],timeout=None)
if (index == 0):
    child.sendline("%s" %command)
    child.logfile = None
    child.interact()
    #child.sendline("%s" %command)
else:
    print("telnet closed,due to EOF")
    child.close(force=True)

如何在不退出telnet的情况下继续执行“ child.interact()”之后的“ child.sendline()”?

或是否有任何方法可以满足要求: 1.远程登录主机 2. telnet会话可以同时处理用户的交互式消息和自动sendline消息。

tbea001 回答:如何在不退出telnet的情况下在“ child.interact()”之后进行“ child.sendline()”?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2831500.html

大家都在问