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:

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 $_; }
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.

So, can anyone suggest a nice, robust and preferably quick way of piping several commands together?

Cheers. BazB


In reply to Robustly piping several processes. by BazB

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.