LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to read from the stderr and stdout buffer? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-read-from-the-stderr-and-stdout-buffer-949142/)

omega341991 06-08-2012 12:41 AM

how to read from the stderr and stdout buffer?
 
I am running a command (say like a tcpdump packet capture ) and the packets details are written into the stdout and stderr. Is there a way to read from the stdout and stderr while the command is still executing?
I already tried the storing the stdout and stderr to a file using

tcpdump >log.txt 2>&1

But in this case the log.txt file is accessible only after the entire capture is over.
Is there a way to retrieve the contents of stdout and stderr while the command is still executing (storing to a variable is also ok )

Please reply

pan64 06-08-2012 03:54 AM

see this page about buffering: http://www.pixelbeat.org/programming/stdio_buffering/
and here are some tips to solve this problem using perl: http://perl.plover.com/FAQs/Buffering.html


All times are GMT -5. The time now is 04:22 PM.