I want to write some commands to a python shell and read the output using the Popen code below -
from subprocess import Popen,PIPE
p = Popen(["python"], stdin=PIPE, stdout=PIPE, shell=True)
out, err = p.communicate("help()\n")
print out.rstrip()
But it doesn't print anything I normally see when I run the help() command in python. What am I missing? Note that I'm using python here as an example, I want to communicate with interactive programs in general using python code.