I have a script that runs two external scripts and one binary file. Each script runs one at a time and before the next one starts, the previous one needs to finish.

I wrote this but it all runs at the same time.

How do I get the suceeding programs to wait for the previous program to finish running before executing?
#!/usr/bin/perl -w use strict; my $pid; my $getSite = "/www/cgi-bin/getSite.pl"; my $createCSV = "/www/cgi-bin/createCSV.pl"; my $createXML = "/www/cgi-bin/csv2xml"; my $siteCSV = "/www/cgi-bin/site.CSV"; my $siteXML = "/www/cgi-bin/site.XML"; unless ($pid = fork) { unless (fork) { exec "$getSite"; die "Couldn't run getSite.pl"; exit 0; } exit 0; } waitpid($pid,0); unless ($pid = fork) { unless (fork) { exec "$createCSV"; die "Couldn't run createCSV.pl"; exit 0; } exit 0; } waitpid($pid,0); unless ($pid = fork) { unless (fork) { exec "$createXML $siteCSV $siteXML"; die "Couldn't run create XML File"; exit 0; } exit 0; } waitpid($pid,0);

In reply to Waiting for an External Program to Finish Executing by awohld

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.