473,661 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7158
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**********@r egistered.motza rella.org>, santosh <sa*********@gm ail.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**********@r egistered.motza rella.org>, santosh
<sa*********@gm ail.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**********@r egistered.motza rella.org>, santosh
<sa*********@gm ail.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**********@r egistered.motza rella.org>, santosh
<sa*********@g mail.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**********@r egistered.motza rella.org>,
santosh <sa*********@gm ail.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
5631
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.* . I have tried the simplest method of capturing stdout, stderr via: saveout = sys.stdout sys.stdout = file_obj
9
2058
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) self.SetTopWindow(frame) return true
3
3424
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
7725
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 buffer ? are they same ? thanks ^^
0
2434
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 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Wait for the process to return
5
2602
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"); PyRun_SimpleString("class a:\n\tdef write(self,s):\n\t\tograbber.grab(s)\n"); PyRun_SimpleString("import sys\nsys.stderr=a()\nsys.stdout=a()"); Its hard to read that way, here's what it expands to:
10
7621
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
8488
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 separate files, but would rather keep the 2 flows together. Is it correct to do this: stderr=freopen(LogFile, "w", stderr); stdout=freopen(LogFile, "a", stdout);
0
2582
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 ProcessTest { class Program
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8758
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7364
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.