Re: [linux-audio-user] A dumb Unix question about console output

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-user] A dumb Unix question about console output
From: Thomas Neuhaus (neuhaus_AT_folkwang-hochschule.de)
Date: Mon Jul 14 2003 - 18:05:42 EEST


Am Sonntag, 13.07.03, um 02:43 Uhr (Europe/Berlin) schrieb Larry
Troxler:

> Hi,
>
> I hesitate to ask this here, since it's gotta be a basic shell thing,
> and
> certainly not audio specific, so if you want to flame me for me OT and
> laziness, go ahead.
>
> The problem is that when I run I run an X application from a console
> (for
> example, "pd &" or "rosegarden &", the console output from all the
> applications I run are interleaved onto the xterm that I started them
> from.
>
> That part is fine.
>
> The part that is not fine, is that the output is not labeled with the
> application that it came from.
>
> For example, I seem to remember that if in the past, if you ran grep,
> for
> example, anything that grep sent to its console would be prefixed by
> "grep:".
> I thought that this was a convention that the apps followed, and not a
> shell
> thing (I seem to remember "printf("%s: ...", argv[0], ....")
>
> Hopefully, I'm wrong about this, and there is a shell option that puts
> the
> application name in front of every line of output. Is there?
>

Unfortunately not. The programs just write to stdout/stderr and the
shell, being just another program
does not even get to see this output. So the only chance is, that the
programs do it themselves.

Otoh doing just printf("%s: ...", argv[0], ....") is probably no what
most users want.
Imagine the output being saved to a file or piped to another program.
So if a program wants to offer this service it should check, if its
writing to a tty
(unix speak for any kind of terminal) and most of the programmers did
not
make this effort for every printf (in pseudo C)

if(isatty(stdout))
        myname=argv[0];
else
        myname="";
printf("%s: ...", myname, ....")

> If it's not something I can make happen in the shell, then how is
> everyone
> dealing with this? Currently I am actually opening a seperate xterm
> for each
> X application that I run, which is quite cumbersome, because it means
> that I
> have to manage twice minus one as many windows as I would if I could
> have all
> the output into one xterm, identified with where it came from.

If you need the output, save it to a file. Dont forget stderr:

pd >& ~/pd.out &

(csh-like)

regards,

Thomas N.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Jul 14 2003 - 18:20:30 EEST