Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

feeding stdin of executed command and store stdout in $var

by gabrielsousa (Sexton)
on Jan 25, 2017 at 13:27 UTC ( #1180290=perlquestion: print w/replies, xml ) Need Help??

gabrielsousa has asked for the wisdom of the Perl Monks concerning the following question:

how i get stdout from this:
to store in $var
open( my $LFTP,'|-', "lftp -u $user,$pass -e open $host " ) || die "Ca +nnot open lftp: $!"; print $LFTP <<"END"; ls END

Replies are listed 'Best First'.
Re: feeding stdin of executed command and store stdout in $var
by Corion (Pope) on Jan 25, 2017 at 13:32 UTC
      i want to list the ftp, and than download some files, not all
      after de "ls" i want to send other command
      but before send other command i want to read what files are in ftp

        Thank you for clarifying what you intend to do.

        Have you tried using Net::FTP instead of lftp? In what way was it unsuitable for your needs?

Re: feeding stdin of executed command and store stdout in $var
by haukex (Bishop) on Jan 25, 2017 at 13:55 UTC

    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

      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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2021-09-28 16:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?