child = pexpect.spawn('/bin/bash -c "echo ba; sleep 1; echo bu"', logfile=
    sys.stdout)
x = child.expect(pexpect.EOF)
child.close()
child.before
Python - capture Popen stdout AND display on console?