home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!eff!ibmpcug!dylan
- From: dylan@ibmpcug.co.uk (Matthew Farwell)
- Subject: Re: csh and redirect of stderr
- Organization: The IBM PC User Group, UK.
- Date: Tue, 18 Aug 1992 18:49:06 GMT
- Message-ID: <Bt709v.B6u@ibmpcug.co.uk>
- Keywords: csh, stderr
- References: <1992Aug18.115253.10164@neptune.inf.ethz.ch>
- Lines: 39
-
- In article <1992Aug18.115253.10164@neptune.inf.ethz.ch> weingart@inf.ethz.ch writes:
- >Ok, I though me a wiz, and now here I am stuck. Well, theoretically
- >I could pull down the sources, and read/muck about, but I simply
- >don't have the time/patience/space to do that right now.
- >
- >If some kind soul could email me how to do the following in
- >csh, I would be gratefull.
- >
- >./someprog foobar 2>/tmp/stderr-out 1>/tmp/stdout-out
-
- This is how you do it in csh.
-
- sh -c "./someprog foobar 2>/tmp/stderr-out 1>/tmp/stdout-out"
-
- >Somehow, >& does not seem to do it.... ;-}
-
- No it doesn't do it. You can't do it in csh. Full stop. You could try
- reading the FAQ for comp.unix.questions, specifically question 2.9
- which, as it happens is entitled - This is not a flame btw:
-
- 9) How do I redirect stdout and stderr separately in csh?
-
- In csh, you can redirect stdout with ">", or stdout and stderr
- together with ">&" but there is no direct way to redirect
- stderr only. The best you can do is
-
- ( command >stdout_file ) >&stderr_file
-
- which runs "command" in a subshell; stdout is redirected inside
- the subshell to stdout_file, and both stdout and stderr from the
- subshell are redirected to stderr_file, but by this point stdout
- has already been redirected so only stderr actually winds up in
- stderr_file.
-
- Sometimes it's easier to let sh do the work for you.
-
- sh -c 'command >stdout_file 2>stderr_file'
-
- Dylan.
-