I currently have this code, whcih works and produces the output you would expect, ie a list of the output lines if you were to run 'ls -ltr | less' from the terminal.
p1 = subprocess.Popen(shlex.split('ls -ltr'), stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
p2 = subprocess.Popen(shlex.split('less'), stdin=p1.stdout,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print p2.communicate()
Is there a way using subprocess.Popen or anything else to get the interactive output you can scroll through and enter keyboard commands into as you would if you ran the commands directly from the terminal?
pexpectfor this sort of thing (although I've never used it myself).