Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!aspect!craig From: craig@aspect.UUCP (Craig Schreiner) Newsgroups: comp.unix.questions Subject: Re: stderr & csh Summary: You need to re-read page 64 Message-ID: <258@aspect.UUCP> Date: 12 Dec 89 17:32:00 GMT References: <1989Dec7.025716.2507@eng.umd.edu> Distribution: usa Organization: Aspect Telecommunications, San Jose, Ca Lines: 37 > This question may sound DUMB, but please read it!!!!!! > Using CSH, how do you redirect ONLY stderr? Before you all say > "idiot, just use >&", try this program....... > > > #include "stdio.h" > /* to compile: cc -o erronly erronly.c */ > /* to run: erronly >& outfile */ > main() > { > fprintf(stderr, "I know you won't believe me "); > fprintf(stdout, "until you read this file!!\n"); > } > > > As stated in THE UNIX C SHELL FIELD GUIDE, written by Gail Anderson & > Paul Anderson, on page 64, ">& also redirects the standard output". If you look again on the top of page 64 you will note the statement: % (find / -name vi -print > /dev/tty) >& /dev/null Essentially you use the () as a command group and redirect its standard output and then redirect it again for standard error. Since standard output has already been redirected the only thing left is the standard error. To run your erronly program you need to issue the command as: % (erronly >stdout) >& stderr to get the results you are looking for! I believe that this question has been answered many times and is in the general postings of news.newusers.questions or in news.announce.newusers.