Pexpect output fails

I have a problem with pexpect not providing any output from the commands that it runs. Ive tried various methods, including the installation we expect, but there are no changes in behavior. For example, when I do this:

#!/usr/bin/python                           
import sys, pexpect 
import os, subprocess, signal 

process = pexpect.spawn('/bin/bash')

process.sendline("export PS1=\"checkout-script:\"\r")
process.sendline("make\r") 
process.expect("checkout-script")
process.sendline("echo $?\r")
process.expect("checkout-script")
print process.before

print "Hello"

There is only an empty string indicating that process.before was empty. Then I type Hello on the next line. Even if I do.

#!/usr/bin/python                           
import sys, pexpect 
import os, subprocess, signal 

process = pexpect.spawn('/bin/bash')

process.sendline("export PS1=\"checkout-script:\"\r")
process.sendline("make\r") 
process.expect("checkout-script")
process.sendline("echo $?\r")
process.expect("checkout-script")
fout = file('mylog.txt','w')
process.sendline("export PS1=\"checkout-script:\"\r")
process.sendline("make\r") 
process.expect("checkout-script")
process.sendline("echo $?\r")
process.expect("checkout-script")
print process.before

print "Hello"

to put input and output in a text file, I see only the input. Please provide some information on how I can fix this problem.

0
source share

All Articles