LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 01: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, 04:54 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:14 AM
how to tell if a file is outputing to STDOUT or STDERR? xskycamefalling Linux - Newbie 5 05-15-2009 01:52 AM
stderr vs stdout sniffer_raghav Programming 2 09-05-2008 11:00 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 03:36 AM
Reopen the stdout and stderr rahul_kulkarni Programming 3 02-21-2005 07:55 AM


All times are GMT -5. The time now is 11:39 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration