使用Python通过终端服务器使用Kermit

2024-04-27 03:32:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从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.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)

有什么办法解决吗?在


Tags: 模块代码echochildifossysexit