sending data to another process's input stream?

Michael P. Reilly arcege at shore.net
Fri May 21 13:53:19 EDT 1999


Paul Prescod <paul at prescod.net> wrote:
: "Joseph J. Strout" wrote:
:> 
:> >I think that the key was that Andrew presumed that the C++ program's only
:> >communication interface was the stdin. Thus he had Python CGIs socketing
:> >to Python long-lived-server piping to stdin.
:>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:> 
:> Right.  This is the bit I don't understand.  How do I do this?

: You can use os.popen2 or something like it. But the trick is that the app
: that calls os.popen can't close or else it loses the file handle. So you
: need a long running Python app.

Not quite correct, Paul.  Taking an example from the print spooling
subsystem, standard input of the C++ program could be redirected from a
"real" named pipe, and the short-lived CGI programs could send msgs to
that without much difficulty in the protocol.  But.. named pipes are
uni-directional, and other mechanisms would have to be made available
to handle communication back: for example, creation of an output file
and signal to the CGI program when data is completed.

Joseph, there are probably a number of different mechanisms to use in
UNIX.  But most will require _some_ amount of changes to the C++ code -
you hadn't said you could change that, but most ppl are assuming you
could.

  -Arcege





More information about the Python-list mailing list