How does one redirect just stderr under the C Shell?

Will Crowder willcr at bud.sos.ivy.isc.com
Thu May 9 10:13:13 AEST 1991


In article <1991May08.154738.26889 at convex.com>, tchrist at convex.COM (Tom
Christiansen) writes:

> From the keyboard of rwl at ee.umr.edu (Wayne Little):
> > [How do I redirect stderr independent of stdout under C Shell?]
>
> In general, it can't be done.  
> 
> Now, I'm sure someone will suggest
> 
>     ( foo > foo.stdout ) >& foo.stderr
> 
> but that's not right: stdout is mangled.

How is stdout mangled?  Is it because "isatty(fileno(stdout))" will no
longer be true?

>                                            Someone else
> will suggest
>
>     ( foo > /dev/tty ) >& foo.stderr
> 
> but that's not right, as stdout is no longer going where it
> had been going.  

Now this, at least, I see.  If the above were part of a pipeline in which
stdout had already been redirected, things would go awry quite quickly, as well
as in a number of other scenarios as well, I'm sure.

Redirector emptor!  :) :) :)

|> If your system should support /dev/fd pseudo-devices, this 
|> ought to work:
|> 
|>     ( foo > /dev/stdout ) >& foo.stderr
|> 
|> But few of us have that feature on our systems.  

I sure wish my system (Sun) did!  That sounds like the right general solution
to me.

Actually, I suggested both of the above in e-mail, with the disclaimer
"I'm no wizard."  Glad I put that disclaimer on there...although I did
get mail back from Wayne saying it worked fine for his particular case.

|> --
|> Tom Christiansen		tchrist at convex.com	convex!tchrist
|> 		"So much mail, so little time." 
                 ^^^^^^^^^^^
That's why I posted this...

Will

--------------------------------------------------------------------------------
Will Crowder, MTS            | "I was gratified to be able to answer quickly,
(willcr at ivy.isc.com)         |  and I did: I said I didn't know."
INTERACTIVE Systems Corp.    |		-- Mark Twain



More information about the Comp.unix.wizards mailing list