BazB has asked for the wisdom of the Perl Monks concerning the following question:
Salutations Fellow Monks,
I'm reasonably familiar with IPC::Open2, IPC::Open3, piped open()s and the like, however I've not yet figured out a nice way to pipe several commands together, in a similar manner to the following in ksh/bash:
cmd1 arg1 arg2 2>cmd1.log | cmd2 arg1 2>cmd2.log | cmd3 2>cmd3.log
$? checking excluded for clarity
Currently, I use an IPC::Open3 based wrapper for each command, and just do the following:
IMHO, that's a horrid way of getting the output from one command into another, and I've not felt the urge to use it with more than two commands at once.execute_cmd(cmd1, @args, $in_fh1, $out_fh1, $err_fh1); execute_cmd(cmd2, @args, $in_fh2, $out_fh2, $err_fh2); while (<$out_fh1>) { print $in_fh2 $_; }
So, can anyone suggest a nice, robust and preferably quick way of piping several commands together?
Cheers. BazB
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Robustly piping several processes.
by IlyaM (Parson) on Dec 26, 2002 at 11:48 UTC | |
Re: Robustly piping several processes.
by pg (Canon) on Dec 25, 2002 at 23:26 UTC | |
by BazB (Priest) on Dec 25, 2002 at 23:43 UTC | |
by pg (Canon) on Dec 26, 2002 at 02:54 UTC | |
by John M. Dlugosz (Monsignor) on Dec 26, 2002 at 03:53 UTC | |
Re: Robustly piping several processes.
by MarkM (Curate) on Dec 26, 2002 at 06:54 UTC | |
Re: Robustly piping several processes.
by Anonymous Monk on Dec 26, 2002 at 00:42 UTC |
Back to
Seekers of Perl Wisdom