I'm trying to structure a Python script that streams output over a pipe.

Here is my code:

import os

cmd = os.popen('echo foo | sudo -S /usr/sbin/tcpdump -en1')
cmd.read()

This returns output of "". I'm expecting the standard output of "tcpdump
-en1". How does one read unbuffered output over a pipe before the pipe
is closed in Python? Because I want the output to be updated in real
time, writing to a temporary file and then reading that data isn't
feasible.

I'm not sure what I'm doing wrong here.

-- 
Kevin Walzer
Poetic Code
http://www.kevin-walzer.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to