LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-08-2012, 12:41 AM   #1
omega341991
Member
 
Registered: May 2012
Posts: 39

Rep: Reputation: Disabled
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
 
Old 06-08-2012, 03:54 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
stderr and stdout timestamp mmhs Linux - Newbie 5 03-16-2012 12:14 AM
how to tell if a file is outputing to STDOUT or STDERR? xskycamefalling Linux - Newbie 5 05-15-2009 12:52 AM
stderr vs stdout sniffer_raghav Programming 2 09-05-2008 10:00 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 02:36 AM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 06:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration