Redirecting stdin/stdout to self

Jan Danielsson jan.danielsson at gmail.com
Mon Jan 23 13:51:49 EST 2006


   Hello, I thought I'd write a program to collect information from pf
(packet filter) and insert it into a postgresql database for review on a
web page. First I checked if this has been done already, and found that
it has.. Using Perl and SQLite in a program called "hatchet".

Well, I want to do it in Python, and I want to use postgresql.

Anyway, upon looking in the hatchet Perl code I found this:

open(IN, "$tcpdump -neltttr $log 2>&1 |");

   That looks kind of funky... And if I'm reading it correctly, the Perl
script's process starts tcpdump, but redirects its output to its own
input, and reads it line by line.

I would normally have done it like this:

$ tcpdump -nelttt pflog0 | mypythonscript.py

   ...however, the Perl script solution looks interresting.. Is it
possible to do something like that in Python?

-- 
Kind Regards,
Jan Danielsson
Te audire non possum. Musa sapientum fixa est in aure.



More information about the Python-list mailing list