Redirecting stdin/stdout to self

Grant Edwards grante at
Mon Jan 23 14:39:00 EST 2006

On 2006-01-23, Grant Edwards <grante at> wrote:
> On 2006-01-23, Jan Danielsson <jan.danielsson at> wrote:
>> 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.
> [...]
>>    ...however, the Perl script solution looks interresting.. Is it
>> possible to do something like that in Python?
> os.popen()

I should have also added that there's a module that allows you
to call libpcap directly (libpcap is the library that tcpdump
uses to capture packets).

It's way, way more efficient than parsing tcpdump's output.  If
you're only grabbing a few packets it may not matter. For some
of the apps I've done, using pylibpcap has cut run-times by a
factor of 10 or more.
Grant Edwards                   grante             Yow!  Life is selling
                                  at               REVOLUTIONARY HAIR

More information about the Python-list mailing list