Need help with input redirection

defender defender at austin.rr.com
Wed May 7 20:00:46 EDT 2003


Greetings All:

I'm looking for a way to redirect input from one program into a python 
program.  For example:

$tcpdump | pythonprog.py

The objective is to take the text output of one running program and pipe 
it into the python program for parsing and processing.  It is important 
during this process that I:

1)  Not use a file as an intermediate step (I can already do that), and
2)  The program feeding my python program *does not terminate*.  That 
is, it keeps running and my python program keeps independently 
processing the input and doing stuff with it while the other program 
continuously feeds it.

This suggests a threading model, which I already know how to do.  The 
piece I haven't figured out is how to get the input into the python 
program in a continuous mode.  I'm assuming it has something to do with 
sys.stdin?

Anyone have any ideas how to continuously feed text data to a python 
program from an external data source that does not terminate?

Any help would be appreciated.

Thanks in advance!

Mark





More information about the Python-list mailing list