I have this program where I'm trying to launch a separate console based application whose output I will monitor and provide appropriate input when asked. But it's getting stuck at
c = proc.stdout.read(1)
Whereas it works perfectly when ran from command line directly
Code snippet:
cmd = "/usr/bin/App.out"
proc = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
c = proc.stdout.read(1)
print c
I have tried plenty of options such as:
- Not using 1 byte buffer with read()
- using readline()
- using TemporaryFile instead of PIPE
- checked root access
- Used communicate() to check if any stderr is there for 'proc', but there is no error