LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-06-2018, 08:07 AM   #1
markus-n
LQ Newbie
 
Registered: Apr 2014
Distribution: Xubuntu, Arch
Posts: 20

Rep: Reputation: Disabled
Why do some tools (e.g. ffprobe) split their output between sdtout and stderr ?


If you want to grep in all output (or want to write all to a file), you always need to 2>&1.

I understand that tools whose purpose is to process some input and write the result to output (e.g. sed) need to handle output and error messages separately. Another example is wget, where you only want to have the downloaded content in stdout. For all these, I think splitting is fine.

But I don't understand this behavior in tools like ffprobe, whose purpose is to analyze a file and then write the result.
 
Old 01-06-2018, 08:32 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,985
Blog Entries: 4

Rep: Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037
STDOUT is intended for "things that you might wish to 'pipe' as input to the next program in the chain." These are "the legitimate outputs" of the program, representing the results that it is tasked to produce.

STDIN is the input-stream of data that a program might expect to have piped-in to it. (If your program needs more-than-one input stream, you have to rig it yourself.)

Meanwhile, STDERR is the chatter-box, where you're talking to the person who is watching the blinking lights. Status messages, error messages, progress messages and so forth. You can instruct the shell to combine the two streams if you wish. You can also divert it to /dev/null, thereby discarding it completely.

Last edited by sundialsvcs; 01-06-2018 at 08:33 AM.
 
1 members found this post helpful.
Old 01-06-2018, 09:38 AM   #3
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
This might be of interest:

https://www.jstorimer.com/blogs/work...tead-of-stdout
 
Old 01-06-2018, 10:06 AM   #4
markus-n
LQ Newbie
 
Registered: Apr 2014
Distribution: Xubuntu, Arch
Posts: 20

Original Poster
Rep: Reputation: Disabled
Well ... then ffprobe is doing it wrong.

when I use ffprobe -show_streams, both stdout and stderr contain information I'm interested in (and that I pipe to grep or less). In this example, stderr contains info about the streams, not error messages.

I've seen this behavior long time ago in other tools, to, but I don't remember which ones.
 
Old 01-06-2018, 10:17 AM   #5
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Have you tried using the -loglevel quiet parameter to see if this makes things more acceptable?
 
Old 01-07-2018, 04:13 PM   #6
markus-n
LQ Newbie
 
Registered: Apr 2014
Distribution: Xubuntu, Arch
Posts: 20

Original Poster
Rep: Reputation: Disabled
It just produces less output, in my use case it omits the meta data info for the container.
 
Old 01-07-2018, 04:21 PM   #7
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by markus-n View Post
It just produces less output, in my use case it omits the meta data info for the container.
Ok. If ffprobe is acting in this way then I suggest, in this particular case, that you contact the ffmpeg guys at https://ffmpeg.org/contact.html and ask them if this is normal and, if not, if they would consider changing the behaviour. I would be interested to hear what they say.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Redirecting output from stderr mwilner Linux - Newbie 5 12-02-2010 08:25 AM
How to redirect stderr from piped output? redss Programming 2 08-21-2009 04:50 PM
How to get stderr output when using a ::system() call tmc3011 Programming 2 01-25-2008 05:17 AM
Any way to split up STDOUT and STDERR, and then recombine in the right order? Lumberg Linux - Software 10 04-18-2006 09:38 AM
captumring output from STDERR rajatgarg Programming 2 01-30-2004 11:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:15 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