[Tutor] input/output redirection

Lane, Frank L frank.l.lane at boeing.com
Thu Sep 8 16:49:39 CEST 2005


Hi List,
 
I wanted to take the stdout of a process and redirect it to stdin of a
python script, then after playing with the input in the script I want to
send it back to stdout (all of this to be done while the original
process runs happily along).  I can't seem to figure out the correct
syntax if this is possible.
 
e.g.
 
C:\> runner.exe | script.py
C:\> runner.exe > script.py  # this overwrites your script!:-)
 
e.g.
 
#!/usr/bin/env python
import re
 
while 1:
    packet = sys.stdin.read()
    if field in packet:
        # change it and put it back on the command window and get the
next bunch of stuff
        sys.stdout.write()
 
I hope my question/intention is clear.
 
Thanks to the list!  This is the best list I've ever belonged to.  There
are a lot of knowledgeable people who help, and no one ever flames you
for asking questions out of ignorance.
 
Thanks,
Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050908/9a0bdc59/attachment.html


More information about the Tutor mailing list