Python how to read output from pexpect child?
child = pexpect.spawn ('/bin/bash') child.sendline('ls') print(child.readline()) print child.before, child.after All I get with this code in my output is ls ls But when my code is child = pexpect.spawn('ls') print(child.readline()) print child.before, child.after Then it works, but only for the first 2 prints. Am I using the wrong send command? I tried send, write, sendline, and couldn't find anymore. Catalin Luta In pexpect the before and after attributes are populated after an expect method. The most common thing used in this situation is waiting for the prompt (so you'll know that the