running "python -i" in subprocess shows no prompt
On Tue, Mar 19, 2019 at 2:50 AM <finnkochinski at keemail.me> wrote:
> I try to start a separate python subprocess using the attached code. This example should catch all stdout and stderr output from the launched subprocess and send commands to its stdin.
> The problem is that the prompt ">>>" asking for then next input is neither sent to stdout nor to stderr. The commands sent to stdin aren't echoed to stdout either.
Many programs behave differently when they're connected to an actual
TTY compared to being connected to a pipe. What you often need to do
is use a pseudo-terminal, which you can then feed stuff to and capture
stuff from. Python makes this available with the pty module:
(I would strongly recommend using Python 3 rather than Python 2, but
it should be possible to do either way.)