473,372 Members | 1,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

what is difference between stdout and stderr ?

when both are connected to screen and the anything written to these
two constant file pointers will go onto the screen ?
Mar 11 '08 #1
7 7132
Cell wrote:
when both are connected to screen and the anything written to these
two constant file pointers will go onto the screen ?
For a standard C program, stdout and stderr both expand to expressions
of type FILE *. They need not be modifiable lvalues, unlike a FILE *
object. They are set, at program start-up to point to the standard
output stream and the standard error stream respectively. To exactly
where these streams connect the standard refrains from specifying, but
on the majority of systems they will connect to the system's output
device, the screen. Typically stdout is line buffered or has full
buffering while stderr is unbuffered, but this can be changed with
setvbuf. You can also use freopen to reorient stdin, stdout and stderr
to point to other named files.

Mar 11 '08 #2
On Tue, 11 Mar 2008 16:46:52 +0530,santosh wrote:

{snip}
>
Why would you want to lose all the error messages? They should go to a
log file or to syslog, not /dev/null, IMO.
That's because the errors are what I expected and I don't need them. ;)
I know this is a special case.
Mar 11 '08 #3
In article <fr**********@registered.motzarella.org>, santosh <sa*********@gmail.comwrote:
>
Why would you want to lose all the error messages? They should go to a
log file or to syslog, not /dev/null, IMO.
Maybe he works for Microsoft...
Mar 11 '08 #4
Doug Miller wrote:
In article <fr**********@registered.motzarella.org>, santosh
<sa*********@gmail.comwrote:
>>
Why would you want to lose all the error messages? They should go to a
log file or to syslog, not /dev/null, IMO.
Maybe he works for Microsoft...
In MS' case of course, the entire program and probably the system too,
disappears into /dev/null. :-)

Mar 11 '08 #5
On Tue, 11 Mar 2008 12:09:36 +0000,Doug Miller wrote:
In article <fr**********@registered.motzarella.org>, santosh
<sa*********@gmail.comwrote:
>>
Why would you want to lose all the error messages? They should go to a
log file or to syslog, not /dev/null, IMO.
Maybe he works for Microsoft...
Unfortunately, I am a student and work for Linux kernel.

Sorry, man.
Mar 11 '08 #6
On Tue, 11 Mar 2008 17:45:43 +0530,santosh wrote:
Doug Miller wrote:
>In article <fr**********@registered.motzarella.org>, santosh
<sa*********@gmail.comwrote:
>>>
Why would you want to lose all the error messages? They should go to a
log file or to syslog, not /dev/null, IMO.
Maybe he works for Microsoft...

In MS' case of course, the entire program and probably the system too,
disappears into /dev/null. :-)
How do you think this special case of mine?

echo -e '#define cat(c,d) c##.d \n #define mb(a,b) a##@b \n mb(cat
(xiyou,wangcong),cat(gmail,com))' \
| gcc -E -xc - 2>/dev/null |tail -n 1

(I already said it's special. ;-)
Mar 11 '08 #7
In article <fr**********@registered.motzarella.org>,
santosh <sa*********@gmail.comwrote:
>WANG Cong wrote:
>And yes, in Linux/Unix, you may want the errors go into a different
direction, e.g. /dev/null, then stdin and stderr differ.

Why would you want to lose all the error messages? They should go to a
log file or to syslog, not /dev/null, IMO.
Because you know what error messages you're expecting, don't want them
to clutter up the output, and don't consider them important enough to
be worth saving to look through afterwards.
(This is obviously not something you want to have happen without
explicitly asking for it. Also, it's extremely rare that error
messages from an interactive program used by a mere mortal should end
up in syslog; if it's something that the people reading the syslog care
about, the system will probably have logged its own error messages
before the error report makes it through the user's program.)

I often find myself saying something like:
grep pattern */* | grep otherpattern
But almost every directory under the current directory has at least one
subdirectory, so grep will whine about not being able to do normal file
I/O on the directory.
Those whines go to stderr, so redirecting stderr to /dev/null will give
me just the output I care about. If that output is broken for some
reason, I can always re-run the grep without redirecting stderr to see
whether the unexpected output is caused by something it's complaining
about.
dave

--
Dave Vandervies dj3vande at eskimo dot com
I was disappointed when I saw the word used in a pre-ANSI draft, and
I am firmly resolved to remain disappointed, no matter the odds.
Harrumph! --Eric Sosman in comp.lang.c
Mar 12 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tsai Li Ming | last post by:
Dear all, I have a problem with a redirecting stdout and stderr. I am a top level module and has no control over the imported modules that are making system calls such as os.system or popen2.* ....
9
by: Alex | last post by:
I'm looking at a tutorial with the code below from wxPython.wx import * class MyApp(wxApp): def OnInit(self): frame = wxFrame(NULL, -1, "winApp", size = (800,640)) frame.Show(true)...
3
by: Laszlo Zsolt Nagy | last post by:
Hello, I have this code: s = smtplib.SMTP() s.set_debuglevel(1) s.connect(host=smtp_host) s.set_debuglevel(0) log("Connected, sending e-mail") sys.stdout.flush()
23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
0
by: Christoph Haas | last post by:
Evening, I'm having trouble with running a process through Python 2.4's subprocess module. Example code: ======================================================== def run(command): run =...
5
by: Wesley Henwood | last post by:
To capture output from python scripts run from a C++ app I've added the following code at the beggening of the C++ app: PyRun_SimpleString("import grabber"); PyRun_SimpleString("import sys");...
10
by: SamG | last post by:
How could i make, from inside the program, to have the stdout and stderr to be printed both to a file as well the terminal(as usual).
2
by: Guillaume Dargaud | last post by:
Hello all, a while ago I was pointed towards freopen as a way to redirect stderr to a log file. It works great, but apparently the app also writes a few lines to stdout. Now I could redirect to 2...
0
by: kreismaler | last post by:
I have some problems to understand the difference of using the STDOUT and using "anonymous pipes" as shown below: using System; using System.Diagnostics; using System.IO; namespace...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.