(Answer) (Category) SCO UnixWare 7/OpenUNIX 8/OpenServer 6 FAQ : (Category) General Information :
What is stdin? What is stdout? What is stderr?
They're called file descriptors.

stdin, standard in, refers to the data stream that is going into a process, which is, by default, taken from the keyboard. But the data characters can be taken from a file, instead, and that's an example of redirecting standard input from a file.

stdout, standard out, refers to the data stream that is coming from a running process. By default, stdout is directed to your screen. Commands like 'ls' and 'cat' display their output to stdout.

stderr, standard error, refers to the data stream of error messages being generated by a process. The registration nag displays itself to stderr, which is usually the console, ctrl-alt-esc. Often stderr is sent to the same place that stdout is directed to.

stdin, stdout and stderr can all be redirected. How to implement this is dependent on your shell.

   Example of redirection with the Bourne shell.
< /pub/phonelist *Would be a stdin redirect > /tmp/printout *Would be a stdout redirect 2> /tmp/errorfile *Would be a stderr redirect
> /dev/null *Would be stdout sent to the null device
pkgchk -n base 2>&1 > /tmp/printout *Would be a stdout redirect to /tmp/printout, and a stderr redirect to stdout's destination

       ./configure > con.log 2>&1        *Would be a stdout redirect to the file
                                          con.log and a stderr redirect to
                                          stdout's destination.  When both
                                          stdout and stderr go to the same
                                          file, you see nothing on the screen.
make > make.log 2>&1 *Would be the same as above.
make 2>&1 | tee make.log *Would be a stderr redirect to the destination of stdout, which is still the display, but then redirect of stdout through a pipe to the command tee, which allows stdout to be displayed normally to the screen while also copying it to make.log.
(same as above but you can see the output as it's going)

< /what/ever/you_want/... *Would be a stdin redirect
> /what/ever/you_want/... *Would be a stdout redirect
2> /what/ever/you_want/... *Would be a stderr redirect

> /dev/null *Would be stdout sent to the null device

Double << >> 2>> *Would append

 pkgchk -n base 2>&1  > /tmp/printout  *Would be a stdout redirect to /tmp/printout, and a stderr redirect to stdout's destination

<mschalit@pacbell.net>

[Append to This Answer]
Previous: (Answer) What are the names of the media devices (like disk, tape, etc...)
Next: (Answer) Why am I suddenly getting not privileged or no permissions errors?
This document is: http://www.zenez.com/cgi-bin/ou8faq/faq?file=18
[Search] [Appearance]
This is a Faq-O-Matic 2.721.