Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Welcome to the Monastery
 
PerlMonks  

Re: How to call a script interactively from perl

by BrowserUk (Pope)
on Oct 08, 2012 at 22:07 UTC ( #997887=note: print w/ replies, xml ) Need Help??


in reply to How to call a script interactively from perl

If the script is a purely command line program that takes its inputs from stdin, you can avoid IPC::open3 by feeding the required interactions to via a pipe.

Say the script requires two lines of input, like this one:

#! perl -slw use strict; chomp( my $interact1 = <STDIN> ); chomp( my $interact2 = <STDIN> ); print "Got: $interact1 $interact2";

Then you can feed it the required inputs and retrieve its output like this:

C:\test>perl -E"$p = open I, '-|', '( echo fred & echo jim ) | interac +t.pl'; say for <I>;" Got: fred jim

This often will not work for programs that expect passwords.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re: How to call a script interactively from perl
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-04-21 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls