Beaker wrote,
>So basically you're saying that the act of evocation is the
>definition, right?

I don't think I understand what you mean by that question...hopefully
something in the verbiage below will cover it...


In the shell, file descriptors are managed using the redirection operators.
When you say

     foobar >output 2>error

you're telling the shell to open the file "output" on file descriptor 1
(standard output), then open the file "error" on file descriptor 2
(standard error), and then run "foobar".  The result is that foobar's
output ends up in "outout", and any error messages it produced are logged
in "error".

You aren't limited to using the "standard" descriptors (0, 1, and 2)...as
in the original printing script example, you can say things like

     foobar 4>baz

which opens the file "baz" on file descriptor 4 before running foobar.
(But this isn't very useful unless foobar was designed to write things on
file descriptor 4.)

File redirections like this only affect the one command they were supplied
on.  If you want the redirection to be permanent, the shell built-in
command "exec" does the trick...for example, if a shell script does

     exec >blah

then for the remainder of the script, all standard output will be
redirected to the file "blah" (unless redirected again by another
redirection operator).


The file redirection operators are as follows:

     [n]<file     open "file" for input on descriptor "n" (default=0)
     [n]>file     open "file" for output on descriptor "n" (default=1)
     [n]>>file    append output to "file" on descriptor "n" (default=1)
     [n]<>file    open "file" for both input and output on descriptor "n"
                  (default=0)
     [n]<&m       get input for descriptor "n" (default=0) from the same
                  place as descriptor "m"
     [n]>&m       send output for descriptor "n" (default=1) to the same
                  place as descriptor "m"
     [n]<&-       close descriptor "n" (default=0)
     &>file       shorthand for ">file 2>&1"

              - Neil Parker
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to