I am trying to open multiple processes in a Perl script on Windows. Program structure would look some thing like this…
my($chld1_out, $chld1_in);
my($chld2_out, $chld2_in);
my($chld3_out, $chld3_in);
my @cmds1=();
my @cmds2=();
my @cmds3=();
$pid1 = open2($chld1_out, $chld1_in, 'ex1.exe')or die $!;
$pid2 = open2($chld2_out, $chld2_in, 'ex2.pl')or die $!;
$pid3 = open2($chld3_out, $chld3_in, 'ex3.exe')or die $!;
print $chld1_in $cmds1[0];
print $chld2_in $cmds2[0];
$op1=<$chld1_out>;
$op2=<$chld2_out>;
if ( $op1 == 'done' && $op1 != 'done')
print $chld1_in $cmds1[0];
elsif ( $op1 != 'done' && $op1 == 'done')
print $chld2_in $cmds2[0];
elsif ( $op1 == 'done' && $op1 == 'done')
print $chld1_in $cmds1[1];
print $chld2_in $cmds2[1];
.....
.....
for loops and while loops..... to process with the data output... and do conditional programming.
close $pid1 or die $!;
close $pid2 or die $!;
close $pid3 or die $!;
If it does how can I execute the Perl script ( ex2.pl )
one way i know is
system($^X,”ex2.pl”,”arg”) ;
I would appreciate fro your help on this ASAP…
Thanks,
-Abishek
Probably not, “opening” a process for reading is usually a fork and a pipe behind the scenes. And fork-execs don’t work on Windows*.
For executing a Perl script, just
doit.And if you want to pass args:
When
ex2.plwants to access@ARGVit will be( 'One', 'Two', 'Three' ). Of course if you want to do any of the perl shorthandARGVtricks, it’s better to localize the GLOB.* – I’ve long thought that a suitable workaround should be possible using Windows process structures which have a readable stdout and stderr, as a well as a writable stdin.