Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I think you are looking for something like IPC::Run3 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.

Below is a contrived example that you can change to meet your own requirements.

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";

And the batch files I used (make 3 files using the below code and name batch1.bat, batch2.bat, and batch3.bat:

@ECHO OFF SET PARAM1=%~1 SET PARAM2=%~2 ECHO BATCH FILE OUTPUT: %PARAM1% %PARAM2% EXIT 0

This results in the following:

F:\ipctest>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


In reply to Re: Tough automation question on windows by tokpela
in thread Tough automation question on windows by kalenz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (8)
    As of 2014-09-20 18:17 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (160 votes), past polls