LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-09-2015, 11:45 AM   #1
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262
Blog Entries: 2

Rep: Reputation: 49
Why does a program like avprobe send normal output to &2?


In this case the program works something like this: you type in `avprobe /foo/bar.wav` and get
Code:
avprobe version 11.4-6:11.4-1~deb8u1, Copyright (c) 2007-2014 the Libav developers
  built on Jun  4 2015 19:39:02 with gcc 4.9.2 (Debian 4.9.2-10)
Input #0, wav, from '/foo/bar.wav':
  Duration: 00:00:04.14, bitrate: 705 kb/s
    Stream #0.0: Audio: pcm_s16le, 44100 Hz, 1 channels, s16, 705 kb/s
# avprobe output
Only the last trivial line comes from standard output; the rest disappears, when using `2> /dev/null`, or when you pipe to `less`.
As far as I know there's a standard output ("&1"), and a standard error output ("&2"). Some programs seem to use the error output for seemingly normal functionality (no errors).
Is there some reason behind it? If so, I'd really like to know, because it's annoying in scripts, and I do some programming as hobby. Or is it just bad practice?
 
Old 07-09-2015, 12:32 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
stdout is used for other data - that you weren't asking for, some of the data that can be sent to stdout is intended to be sent to other applications...
 
Old 07-12-2015, 10:24 AM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
In days of old you would pipe your data from ffmpeg/avconv to ffmpeg/avconv. Like if you wanted to change the framerate without skipping or adding frames. So sending messages to stderr lets you keep stdout for your data path. While still being able to see the progress.
 
Old 07-12-2015, 10:38 AM   #4
Weapon S
Member
 
Registered: May 2011
Location: Netherlands
Distribution: Debian, Archlinux
Posts: 262

Original Poster
Blog Entries: 2

Rep: Reputation: 49
If I understand correctly, stdout used to be reserved for the actual media-data with ffmpeg/avconv, and so the text output goes to stderr. Thanks for explaining.
 
  


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
[SOLVED] How to run a single program on consecutive files and send output to new files. WeiYi Linux - Newbie 7 06-29-2012 11:29 PM
[SOLVED] how to send the output of send command to a file auma78 Linux - Newbie 2 01-23-2011 12:06 AM
how to send snmp trap & recieve trap in C program minil Programming 3 07-10-2010 09:22 AM
Make a program can collect linux command output regularly and send to a tftp server fragon Programming 2 04-07-2008 04:49 PM
in Pascal: how to exec a program, discard text output or send to text file Valkyrie_of_valhalla Programming 6 05-02-2007 09:50 AM

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

All times are GMT -5. The time now is 08:58 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
Open Source Consulting | Domain Registration