Re: one final observation on my piping to multiple processes.

2011-02-10 Thread Larry Ploetz
On 2/10/11 12:15 PM, Philip Rowlands wrote:
>
>
> One final note; the pee utility included in the moreutils package does
> exactly what you want without the funky shell syntax.
>
>
Funky syntax?!? I take exception to that, sir. ;-)

Larry "I *like* bash; I really do" Ploetz
--

  
*Larry Ploetz
Systems Administrator
Carnegie Institution for Science
Department of Plant Biology
The Arabidopsis Information Resource
650 739 4296 la...@tairgroup.org *


--
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
--
For more information on Linux on System z, visit
http://wiki.linuxvm.org/


Re: one final observation on my piping to multiple processes.

2011-02-10 Thread Philip Rowlands

On 10/02/2011 14:23, McKown, John wrote:

The use of>(...) and tee seem to be what I need to pipe the output
from bzcat to muliple perl scripts. But I found a "bug" in my
original:

bzcat data*bz2| tee>(perl script1.pl) | perl script2.pl

The stdout from script1.pl is piped into script2.pl ater the bzcat'ed
data. So I need to do something like:

bzcat data*bz2 | tee>(perl script1.pl>/dev/fd/2)|perl script2.pl

that way the output from script1.pl is send to stderr instead of
stdout, and does not end up going into script2.pl.


A better model might be
$ a | tee >(b) >(c) >(d) > /dev/null

i.e. explicitly throw away tee's stdout. This doesn't upset b/c/d's
stdout as bash's process substitution occurs before the file
redirection. However don't depend too much on the order (or worse,
buffering) of the process-substitution stages' output.

Confusingly, pipelines are constructed in a different order, so this
behaves differently:
$ a | tee >(b) >(c) | d

by sending a, b and c's stdout to d's stdin.

One final note; the pee utility included in the moreutils package does
exactly what you want without the funky shell syntax.


Cheers,
Phil

--
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
--
For more information on Linux on System z, visit
http://wiki.linuxvm.org/


one final observation on my piping to multiple processes.

2011-02-10 Thread McKown, John
The use of >(...) and tee seem to be what I need to pipe the output from bzcat 
to muliple perl scripts. But I found a "bug" in my original:

bzcat data*bz2| tee >(perl script1.pl) | perl script2.pl

The stdout from script1.pl is piped into script2.pl ater the bzcat'ed data. So 
I need to do something like:

bzcat data*bz2 | tee >(perl script1.pl >/dev/fd/2)|perl script2.pl

that way the output from script1.pl is send to stderr instead of stdout, and 
does not end up going into script2.pl.

Again, many thanks for this neat way to reduce my run-time.

John McKown
Systems Engineer IV
IT

Administrative Services Group

HealthMarkets(r)

9151 Boulevard 26 * N. Richland Hills * TX 76010
(817) 255-3225 phone *
john.mck...@healthmarkets.com * www.HealthMarkets.com

Confidentiality Notice: This e-mail message may contain confidential or 
proprietary information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. 
HealthMarkets(r) is the brand name for products underwritten and issued by the 
insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance 
Company(r), Mid-West National Life Insurance Company of TennesseeSM and The 
MEGA Life and Health Insurance Company.SM


--
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
--
For more information on Linux on System z, visit
http://wiki.linuxvm.org/