Question about pipes/os.popen
Kevin Walzer
kw at kevin-walzer.com
Fri Sep 15 10:42:32 EDT 2006
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
More information about the Python-list
mailing list