从python通过终端服务器使用kermit
我想从Python代码中通过终端服务器使用kermit。我试图用pexpect模块解决这个问题,但在生成后,它用EOF注销,所以孩子死了从python通过终端服务器使用kermit,python,pexpect,terminal-server,kermit,Python,Pexpect,Terminal Server,Kermit,我想从Python代码中通过终端服务器使用kermit。我试图用pexpect模块解决这个问题,但在生成后,它用EOF注销,所以孩子死了 child = pexpect.spawn('echo os.environ["MODULESHOME"]/init/sh; module add kermit; kermit kermit-vpp.kermit -- ' + target + ' ' + port) child.maxread=1000 i = child.expe
child = pexpect.spawn('echo os.environ["MODULESHOME"]/init/sh; module add kermit; kermit kermit-vpp.kermit -- ' + target + ' ' + port)
child.maxread=1000
i = child.expect_exact(['-----------', 'U-Boot', pexpect.EOF, pexpect.TIMEOUT], timeout=20)
print child.before
if i == 1:
print '****Timeout'
sys.exit(1)
if i == 2:
print '****Eof'
sys.exit(1)
有什么办法解决这个问题吗?if i==1行不应该是if i==3吗?超时是您列表中的第三项…我是说,第四项。这是l[3],因为基于0的索引。Yoy是对的,但它不会改变任何东西。我认为问题在于您传递了多个以;分隔的命令;。spawn需要一个命令。有没有一种单一的命令方式来启动它?或者您可以使用sh-c生成一个shell,然后运行多个命令。