<?xml version="1.0" encoding="windows-1252"?>
<node id="835225" title="Re: Tough automation question on windows" created="2010-04-17 00:16:38" updated="2010-04-17 00:16:38">
<type id="11">
note</type>
<author id="62157">
tokpela</author>
<data>
<field name="doctext">
&lt;p&gt;
I think you are looking for something like &lt;a href="http://search.cpan.org/search?query=IPC%3A%3ARun3"&gt;IPC::Run3&lt;/a&gt; which would allow you to run a program, capture the output to a variable, parse the variable and then run another command with parameters derived from the output of the preceding command.
&lt;p&gt;
&lt;p&gt;
Below is a contrived example that you can change to meet your own requirements.
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;
use strict;
use warnings;

use IPC::Run3;    

my @command1 = ('batch1.bat', 'BF1_PARAM1', 'BF1_PARAM2');
my ($in1, $out1, $err1);

run3 \@command1, \$in1, \$out1, \$err1;

chomp($out1);
print "BATCH FILE 1: [$out1]\n";

my @command2 = ('batch2.bat');
my ($in2, $out2, $err2);

if ($out1 =~ /batch\s+file\s+output/i) {
   push(@command2, 'BF2-PARAM1');
   push(@command2, 'BF2-PARAM2');
}

run3 \@command2, \$in2, \$out2, \$err2;

chomp($out2);
print "BATCH FILE 2: [$out2]\n";

my @command3 = ('batch3.bat');
my ($in3, $out3, $err3);

if ($out2 =~ /batch\s+file\s+output/i) {
   push(@command3, 'BF3-PARAM1');
   push(@command3, 'BF3-PARAM2');
}

run3 \@command3, \$in3, \$out3, \$err3;

chomp($out3);
print "BATCH FILE 3: [$out3]\n";

print "Done\n";
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
And the batch files I used (make 3 files using the below code and name batch1.bat, batch2.bat, and batch3.bat:
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;

@ECHO OFF

SET PARAM1=%~1
SET PARAM2=%~2

ECHO BATCH FILE OUTPUT: %PARAM1% %PARAM2% 

EXIT 0
&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
This results in the following:
&lt;code&gt;
F:\ipctest&gt;perl ipc_run3_test.pl
BATCH FILE 1: [BATCH FILE OUTPUT: BF1_PARAM1 BF1_PARAM2 ]
BATCH FILE 2: [BATCH FILE OUTPUT: BF2-PARAM1 BF2-PARAM2 ]
BATCH FILE 3: [BATCH FILE OUTPUT: BF3-PARAM1 BF3-PARAM2 ]
Done
&lt;/code&gt;
&lt;/p&gt;

</field>
<field name="root_node">
835099</field>
<field name="parent_node">
835099</field>
</data>
</node>
