1

I would like to use kermit through terminal server from a Python code. I tried to solve it with pexpect module but after the spawn it logs out with EOF so the child is dead.

    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)

Is there any idea to solve it?

Skizo-ozᴉʞS ツ
  • 19,464
  • 18
  • 81
  • 148
user2968409
  • 99
  • 1
  • 2
  • 4
  • Shouldn't your `if i == 1` line be `if i == 3`? Timeout is the third entry in your list. – Thomas K Nov 08 '13 at 18:09
  • ...I mean, the fourth entry. Which is `l[3]`, because of 0-based indexing. – Thomas K Nov 08 '13 at 18:33
  • Yoy are right, but it does not change anything. – user2968409 Nov 14 '13 at 08:05
  • I think the problem is that you're passing multiple commands separated by `;`. `spawn` expects a single command. Is there a single command way to start it? Or you could spawn a shell using `sh -c` and then run multiple commands. – Thomas K Nov 16 '13 at 02:37

0 Answers0