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: Gustavo Zamorano S. (gzsuniq_AT_cableonda.net)
Date: Sun Jul 13 2003 - 06:44:56 EEST


OH! You also want the std. output.
I read the shell given by toby_AT_tobiah.org and it is also a good solution.
You can pipe things to sed, awk which are the most commonly used
commands for editing the std. output using pipes. That is, without
using temp files.
As you can see, Toby's example does not use sed, awk. It uses echo. But,
he has to use a while loop.

So, you can have:

A 4 line shell script called runit :

# runit command options
cmd=$1
# In case $1 has sub directories, then get just the command name
cmd=`basename $cmd`
#
expr="s?^?${cmd}: ?"
eval `echo "$* 2>&1 | sed '$expr' " `

This script can be installed under /usr/bin .

To run a command type:

runit [command] [command_options]

Standard output and std. errors will be displayed on the xterm with
command name included.

After all, what I love in Unix is that YOU CAN do these kind of things.
  Everything is possible.
I recognize that to be able to do this 4 line script takes too much Unix
experience.

I am using basename to get the filename in case you run:

runit /usr/local/bin/netscape &

I define expr to create the argument sed expects. I use quetion marks
to avoid conflicts with slashes.

Life is harder on any other MOST popular operating systems...specially
those that crash so often in a daily basis.

GZS

Larry Troxler wrote:
> On Saturday 12 July 2003 22:13, toby_AT_tobiah.org wrote:
> < I mean, how would you like it if
>
>>you typed 'ls', only to get back:
>>
>>ls: slow.wav
>
>
> ...
>
> Ahh, I see your point now.
>
>
>>Create an executable shell script in your path that looks like this:
>>
>>
>>#***** SCRIPT *****
>>function showme(){
>> while read foo
>> do echo $1: $foo
>> done
>>}
>>
>>$@ | showme $1
>>#***** /SCRIPT *****
>>
>>I called mine, "identify".
>>
>>Now, let's test it with grep:
>>
>>sinewave:toby:toby> identify grep foo *
>>grep: Binary file DSC00326.TIF matches
>>grep: Binary file QtC-0.0.2.lsm matches
>>grep: adf: afsdadsfadfasdfasdfasdfasdfasdfasdf toby adfadfadf foo
>>grep: adf: print('myfoot', 'myfoot');
>>grep: adf: print('yourfoot', 'yourfoot');
>>grep: doit: while read foo
>>grep: doit: do echo $1: $foo
>>
>>So, now stdout and stderr get prefixed with the name
>>of the program. Easy, yes?
>>
>>
>>Tobiah
>
>
> Well, ok, maybe easy, but still ...
>
> I guess the answer to my original question is that, yes, people fire up a
> seperate xterm for each audio app they launch :-)
>
> I mean, I have a hard time believing that what you're describing is common
> practice.
>
> Thanks for your time! (really, thanks!)
>
> Regards
>
> Larry Troxler
>
>
>
>

-- 
This Message is sent from my Red Hat 8.0 Linux server

.-. .-. | Gustavo Zamorano S.


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

This archive was generated by hypermail 2b28 : Sun Jul 13 2003 - 06:50:44 EEST