popen3 stdin problem

Donn Cave donn at drizzle.com
Mon Nov 26 12:40:18 EST 2001


Quoth en at enlightened.de (Nicolai Ehemann):
| I have a strange problem using popen3() on a linux machine with python
| 2.1.1:
| I use
|
|   inf, outf, erff os.popen3("cmd ....")
|
| to start a process which makes a lot of output to stdout and awaits
| user input on stdin. Capturing the output with outf.readline() works
| perfectly, but as far as I can see sending input to the process via
| inf.write("command") or inf.write("command\n") does not get through to
| the child process. When called interactively, cmd reacts to input from
| stdin with some status output, and there is a /QUIT-Command which
| should stop the program. Nothing of this happens (outf.readline()
| never gets EOF).
|
| Any ideas what the problem could be?

Try
    inf.flush()

after writing.  The functions in popen2 return file objects, which
will be block buffered.  You have to flush manually, or use the
underlying file descriptors (fileno()).

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list