From: Tobiah on
Sometimes I use the 'tee' command so that I
can see output while it's being generated,
but still saving it to a file.

It would be nice if I could see the output,
but still redirect the output to a pipe:

data_maker | tee --use_stderr | data_taker

If tee had a flag like that, I could see the
data on stderr, while still piping it to
the receiving process.

Is there some other way to do this?

Thanks,

Tobiah
From: Seebs on
On 2010-04-20, Tobiah <toby(a)rcsreg.com> wrote:
> Sometimes I use the 'tee' command so that I
> can see output while it's being generated,
> but still saving it to a file.
>
> It would be nice if I could see the output,
> but still redirect the output to a pipe:
>
> data_maker | tee --use_stderr | data_taker
>
> If tee had a flag like that, I could see the
> data on stderr, while still piping it to
> the receiving process.
>
> Is there some other way to do this?

.... | tee /dev/fd/2 | ...

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Jon LaBadie on
Seebs wrote:
> On 2010-04-22, Jon LaBadie <jlabadie(a)aXcXm.org> wrote:
>> As this is running in a "terminal", why not use /dev/tty?
>
> Because the question asked was how to tee to stderr, I thought?
> Anyway, /dev/tty is obviously better if you want the terminal
> regardless of where stderr is going...
>

They did. I was doing some mind-reading and based on the OP's
statement that they wanted output to their terminal, I felt
the they asked about stderr because tee's stdout was going to
the pipeline. Thus I think their real need was how to get
tee's output to the pipe and to the terminal.
From: Jon LaBadie on
Seebs wrote:
> On 2010-04-21, Tobiah <toby(a)rcsreg.com> wrote:
>>>> If tee had a flag like that, I could see the data on stderr, while
>>>> still piping it to the receiving process.
>
>>>> Is there some other way to do this?
>
>>> ... | tee /dev/fd/2 | ...
>
>> That's pretty neat. How portable is that?
>
> On modern systems, "pretty portable". I think I've seen /dev/stderr
> as far back as 10-20 years ago.
>

As this is running in a "terminal", why not use /dev/tty?

Or don't POSIX/SUS require /dev/tty to be present?
It exists on each of the 4 old and current systems I
have available to check.

It was always useful to get output to the user's terminal
when stdout was redirected.
From: William Ahern on
Jon LaBadie <jlabadie(a)axcxm.org> wrote:
>
> As this is running in a "terminal", why not use /dev/tty?
>
> Or don't POSIX/SUS require /dev/tty to be present?

It does. Section 10.1 requires conforming systems to have /, /tmp,
/dev/console, /dev/null, and /dev/tty. And /dev/tty is a reference to the
process group's controlling terminal.