in reply to feeding stdin of executed command and store stdout in $var

Hi gabrielsousa,

Like Corion, I'd strongly recommend using a Perl module like Net::FTP. If however for some reason you really need to talk to an external program, I can recommend IPC::Run, or perhaps Expect.

Regards,
-- Hauke D

  • Comment on Re: feeding stdin of executed command and store stdout in $var

Replies are listed 'Best First'.
Re^2: feeding stdin of executed command and store stdout in $var
by gabrielsousa (Sexton) on Jan 25, 2017 at 14:26 UTC
    how i send several commands with IPC::run ?

      Hi gabrielsousa,

      how i send several commands with IPC::run ?

      IPC::Run's interface takes a little bit of getting used to, but have a look at the doc and example code of the pump() function.

      Regards,
      -- Hauke D

        my @cmd=('lftp', '-u', "$user,$pass", '-e', "open", "$host"); my $h = start \@cmd, \$in, \$out, \$err, timeout( 10 ); $in .= "ls\n"; $in .= "ls\n"; pump $h; print $out; finish $h;
        do not work :( only print after the finish $h;