Dear perl monks,
I am struggling to keep my pipe open long enough so that the underlying command has the time to complete.
This is my code:
state $rsync_base_cmd = "rsync -avm -L --exclude='S/' --include='*/' + --include='*.cpp' " . "--include='*.hpp' --exclude='*'"; # perform the copy my $command = "$rsync_base_cmd ${login}:${remoteDirectory} $localDir +ectory"; #print("\n$command\n"); # for debugging #`$command`; my $output = ""; my $pid = open3(undef, my $pipe, undef, $command) or confess("[_copy_component] Cannot perform rsync : $!"); while(<$pipe>){ $output .= $_; } # wait it completes to process eval { close ($pipe); }; waitpid($pid, 0);
Unfortunately the pipe terminates before the command is able to copy all the involved files. But if I print the output into the stdout, then the pipe will correctly finish and all the files will be copied.

Can you please tell me how to ensure the underlying command completes without having to print the output into the stdout?

Kind regards,
Superfox

In reply to Premature close of the pipe by Superfox il Volpone

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.