reid@unitek.UUCP (Reid Spencer) (11/30/85)
Does anyone know how to direct the standard output (fd 1) and the standard error (fd 2) to different places with the C Shell? For example, I am trying to generate an index using nroff. The index is generated on standard error while the document is generated on standard output. Using the Bourne Shell, the command is: nroff -ms document > doc 2> index There is no equivalent (that I have found) in the C Shell. Is anyone more enlightened than I am? Please send mail to me. If there is enough interest, I will post the results. Reid Spencer ...!ubc-vision!unitek!reid
greid@adobe.UUCP (Glenn Reid) (12/03/85)
Here is a technique that will work. The premise is that you *cannot* redirect the two channels to two different places with the c-shell. The solution is to use a subshell from the c-shell. > example for sh(1): > nroff -ms document > doc 2> index A hack that will work with csh(1): (nroff -ms document > doc) >& index The parentheses create a subshell which will run nroff. The standard output from the nroff program will be redirected into the file "doc". Anything written to the standard error channel will be visible the standard error channel of the subshell (in parens), which can then be redirected into index. Glenn Reid ..decwrl!adobe!greid -- Skipping unavailable article...
reid@unitek.UUCP (Reid Spencer) (12/03/85)
[Sigh] Recently (last week), I posted an inquiry for information on how to separate the standard error from the standard output using the C Shell. I have received several messages and there seems to be two solutions - one of which is more popular than the other. I thank all those who took the time to respond. My problem was: How do you redirect the standard error of a job to a different place than the standard output. For example, using Bourne Shell, we would do the following: nroff -ms document >doc 2>index In the C Shell, the solution seems to be: Use brackets to run the job in a sub-shell and redirect the I/O at two different levels: (this is the popular one) (nroff -ms document >doc) >& index Or, using the Bourne Shell: sh -c 'nroff -ms document >doc 2>index' Both versions work quite well - I haven't decided which I like better yet, but I am grateful for all the responses. Thanks again. Reid Spencer ...!ubc-vision!unitek!reid