program I feed in interactively as below
child.before contains the expected data (output of expect command)
I run the code as python progname.py: (code shown below example run on pastebin)
import pexpect
import sys
child = pexpect.spawn('gdb',logfile=sys.stdout)
try:
child.expect(pexpect.EOF,timeout=0)
except Exception, e:
print child.before
import code;code.interact(local=locals())
and child.before is null
Why is that? I would expect that commands fed in interactively would produce the same
results as a program run by python progname.py
The import code; code.interact(local=locals()) is there to get me into the python
shell to play around
print child.before in the program produces nothing -- it should produce the output of the gdb command
I am using child.expect(pexpect.EOF,timeout=0) because I want the immediate output of
any command that I produce without looking for carriage return/lf etc or the prompt of a command
anyone?