Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Premature close of the pipe

by McA (Priest)
on Apr 09, 2014 at 13:43 UTC ( [id://1081648]=note: print w/replies, xml ) Need Help??


in reply to Premature close of the pipe

Hi,

it is not a direct answer to your question and I don't know whether your code is just an excerpt from a bigger context. But if you just want to call rsync with grabbing the output synchronosly you could use the following:

my $rsync_base_cmd = "rsync -avm -L --exclude='S/' --include='*/' --in +clude='*.cpp' " . "--include='*.hpp' --exclude='*'"; my $command = "$rsync_base_cmd ${login}:${remoteDirectory} $localDirec +tory"; open my $fh, '-|', $command or confess("_copy_component Cannot perform rsync : $!"); my $output; while(<$fh>) { $output .= $_; } close $fh or confess("rsync problem: $!");

Best regards
McA

P.S.: untested

Replies are listed 'Best First'.
Re^2: Premature close of the pipe
by Superfox il Volpone (Sexton) on Apr 09, 2014 at 14:59 UTC
    Hi McA,
    thanks for your reply.

    Well, I do not wish to necessarily grab the output from the pipe, the statement while(<$fh>) { $output .= $_; } was a trick to delay the premature death of the pipe.
    I am using open3 because the remote server prints into the stderr a welcome message, which it is automatically forwarded into the client stdout using the common pipe mechanism, while I want to get rid of it.

    Kind regards,
    Superfox

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1081648]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-16 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found