I/O Redirection question

Mayank Prakash prakash at fyrpwr.enet.dec.com
Thu Apr 18 00:26:34 AEST 1991


In article <BROWNING.91Apr15152400 at ew10.nas.nasa.gov>, browning at nas.nasa.gov (David S. Browning)
writes:
|->In article <1991Apr11.144844.28800 at riacs.edu> dwsmith at loki.arc.NASA.GOV (David Smith) writes:
|->
|->   I have a question regarding I/O redirection.  I have a program in which
|->   writes to stdout and stderr.  I have redirected both of these to a file.
|->
|->   Now comes the problem.  I need to capture stdout in a file along with
|->   stderr, but I also need stdout to go to the terminal for prompting of
|->   input.  Is this possible?  If so, how does one do this?
|->
|->I have a related question.  Is it possible, in csh, to redirect stdout
|->and stderr to different files?  Or to redirect stderr and not stdout?
|->I know how to do it in sh/ksh, but not in csh.
|->
|->Thanks,
|->David
|->
--

In csh, try the following -

(cmd > outfile) >& errfile

to send stdout of cmd to outfile, and stderr to errfile. To redirect
stderr, and not stdout, is a bit harder. If stdout is the terminal, the
following would work -

(cmd | tee /dev/tty > /dev/null) >& errfile

It should give you ideas of how to do it in general.

-mayank.

+--------------------------------------------------------------------------+
| InterNet: Prakash at AIAG.ENET.DEC.COM                                      |
| UUCP:     ...!decwrl!aiag.enet.dec.com!Prakash                           |
| VoiceNet: (508)490.8139                                                  |
| BitNet:   prakash%aiag.enet at decwrl.dec.com                            |
| SnailNet: DEC, 290 Donald Lynch Blvd. DLB5-2/B4, Marlboro, MA 01752-0749 |
+--------------------------------------------------------------------------+

Disclaimer: The above is probably only line noise, and does not reflect the 
            opinions of anybody, including mine, far less my employer's.



More information about the Comp.unix.shell mailing list