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.
|
|---|