Section 3.5. Input, Output, and Error Channels


[Page 45 (continued)]

3.5. Input, Output, and Error Channels

In the example of the date command above, the output was written to the terminal window. Linux can write to files, but there are three default I/O channels that are always assumed active for every command or program.

  • Standard input, known as "stdin," where a program expects to find input.

  • Standard output, known as "stdout," where a program writes its output by default.

  • Standard error, known as "stderr," where a program writes error messages.

By default, all three I/O channels are the terminal running the command or program. This enables commands to interact with the terminal easily and still use input from other places and write output to other places when necessary. The default I/O channels can be easily changed on the command line by using "redirection." We'll see examples of I/O redirection later in this chapter. For details on how the Linux I/O channels work see Chapter 12, "Systems Programming."




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net