Changing interact to expect eof worked for me!
Here is what the above code is Doing:
1. We create a new process object.
2. We set the stdin, stdout, and stderr attributes of the process object to PIPE.
3. We call the Popen.communicate() method.
4. We pass the input to the stdin.
5. We read the output from the stdout.
6. We read the error from the stderr.
7. We wait for the process to terminate.