I have a python script which tries to execute external programs.
My project involves a python talk bot through which the client should be able to execute commands in the remote terminal.

So basically the module incorporating the talk bot allows me only to get inputs and send output.I need to take the input and see if it is a terminal command and execute it.

So I used the subprocess.Popen object to implement this.

The problem is, if the command calls a program which is interactive, ie. waits for an input and gives output, I am not able to handle it. In the best case, Popen waits for all inputs and then gives the output.

Is there a way to do this properly, ie. start an external program and send input, get output; send input, get output and so on.