Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] stdin/stderr redirection under Solaris



Quoting br@example.com:
> Or, if you prefer to avoid fifos:
>
> test.sh:
>   #! /bin/sh
>   echo "standard output" >&1
>   echo "STANDARD ERROR" >&2
>
> This command will do what you want, I guess (at least in bash):
> $ (./test.sh | tr a-z A-Z) 3>&1 1>&2 2>&3 | tr A-Z a-z
>
> The first "tr" receives stdout as input, and the second one receives
> stderr as input.
> Take care of one thing: The current state of stdout/stderr is messed up
> then. You may want to restore them, in case you have another pipe
> following, for instance:
> $ (((./test.sh | tr a-z A-Z) 3>&1 1>&2 2>&3 | tr A-Z a-z) 3>&1 1>&2 2>&3)

Ooops. Use instead a "cat > OUT" and "cat > ERR" in my two examples (instead
of "tr"), and you will understand what happens, i.e. the second cat received
stderr as input.
In my previous examples, the output of the first "tr" seems to be filtered
again -partially- by the second one on my 5.8 box (it does not happen on
Linux, strangely).

I don't understand this different behaviour. Maybe the versions of bash?
(2.0.3 vs 2.0.5b)

br.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links