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

Thomas Neuhaus neuhaus at folkwang-hochschule.de
Mon Jul 14 11:27:01 EDT 2003


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.




More information about the Linux-audio-user mailing list