in reply to IPC::Run - can i print the $out before the finish

Hi gabrielsousa,

The documentation I linked you to contains example code that shows how to interact with smbclient, which should be very similar to interacting with an FTP client. It shows how to use a while loop to continually call pump until the next prompt is seen.

Regards,
-- Hauke D

Replies are listed 'Best First'.
Re^2: IPC::Run - can i print the $out before the finish
by gabrielsousa (Sexton) on Jan 25, 2017 at 23:41 UTC
    manage to make it work, thanks
    my ($user,$pass,$host,$in,$out,$err)=('eurotuxftpprod','KujRemebeuj0', +"$ARGV[0]","","",""); use IPC::Run qw( start pump finish timeout ); my @cmd=('lftp', '-u', "$user,$pass", '-e', "open", "$host"); my $h = start \@cmd, \$in, \$out, \$err, timeout( 5 ); $in .= "cls -1\n"; pump $h until $out || $err; # =~ /input/ ; print $out; $out = '' ; $in .= "ls\n"; pump $h until $out || $err; # =~ /input/ ; print $out; $out = '' ; $in .= "mget *\n"; pump $h until $out || $err; # =~ /input/ ; print $out; print $err; finish $h;
Re^2: IPC::Run - can i print the $out before the finish
by gabrielsousa (Sexton) on Jan 25, 2017 at 22:08 UTC
    manage to make it working. have a strange thing, the output is always of the first command :(
    what i'm doing wrong
    use IPC::Run qw( start pump finish timeout new_chunker); my @cmd=('lftp', '-u', "$user,$pass", '-e', "open", "$host"); #my $h = start \@cmd, \$in, \$out, \$err, timeout( 5 ); my $h = start \@cmd, \$in, '>' => new_chunker, sub { push @out, @_ }, + timeout( 5 ); $in = "cls -1\n"; pump $h until @out; print @out; $in = "ls\n"; pump $h until @out; print @out; print @out; finish $h;