The short answer is make each script exit with 1 for success or 0 on error and then

do '1-search_user.pl' or die; do '2-prepare_2update_user.pl' or die; do '3-backup.pl' or die; do '4-run_update.pl' or die;
But that isn't really the best solution. I would either combine the four scripts into one script or put the functionality into a module. The first solution looks like
search_user(); prepare_2update_user(); backup(); run_update(); sub search_user { ... } etc
Are these scripts used elsewhere? If so then I'd go for a module and the script would then look like.
use MyModule; MyModule::search_user(); MyModule::prepare_2update_user(); MyModule::backup(); MyModule::run_update();
In either case each function throws it's own exception so you don't check for errors if all you want to do is exit.

To get started with modules see Simple Module Tutorial

The script executes sequentially and it can be run from cron, you will need to ensure that it can find the other scripts, environment variables may not be set so do '/path/to/script' or push @INC, '/path/to' may be necessary.


In reply to Re: Executing multiple scripts sequentially by hipowls
in thread Executing multiple scripts sequentially by fabster01

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.