Page 102 - 500
P. 102

Standard Output and Standard Error

                            Programs can be written to send their output to either the standard
                            output device or the standard error device. Sometimes programs
                            are written to send different types of output to each device. You
                            can't always tell which is which because, by default, both devices
                            are the screen.
                            The  Windows  2000  Type  command  illustrates  the  difference.
                            When used with wildcards (something you can't do with the Type
                            command in MS-DOS or Windows 9x), Type sends the name of
                            each matching file to standard error and sends the contents of the
                            file to standard output. Because they both go to the screen, you see
                            a nice display with each file name followed by its contents.
                            However, if you try to redirect output to a
                            file like this:
                             type *.bat > std.out
                            the file names still appear on your screen because standard error is
                            still directed to the screen. Only the file contents are redirected to
                            Std.out.
                            Windows  2000  allows  you  to  qualify  the  redirection  symbol  by
                            preceding  it  with  a  number.  Use  1>  (or  simply  >)  for  standard
                            output and 2> for standard error. For example:
                            type *.bat 2> err.out
                            This  time  the  file  contents  go  to  the  screen  and  the  names  are
                            redirected to Err.out. You can redirect both to separate files with
                            this command line:
                            type  *.bat  2>  err.out  1>  std.out

                                                The Pipe Symbol
                            The  pipe  symbol  (|)  is  used  to  send,  or  pipe,  the  output  of  one
                            program  to  a  second  program  as  the  second  program's  input.
                            Piping  is  commonly  used  with  the  More  utility,  which  displays
                            multiple screens of output one screenful at a time. For example:
                            help dir   |   more
                            This command line uses the output of Help as the input for More.
                            The More command filters out the first screenful of Help output,
                            sends  it  to  the  screen  as  its  own  output,  and  then  waits  for  a
                            keypress before sending more filtered output.
   97   98   99   100   101   102   103   104   105   106   107