Script3.pl would be run if script2.pl died.

To prevent it, use

script1.pl script2.pl && script3.pl

Script2 will always be run regardless of how script1 exits. Script3 will only be be run if script2 succeeds -- Ie. returns 0, which it won't if it dies or exits with any value other than 0.

You can also do

script1 || script2;

In which case, script2 will only be run if script1 fails.

P:\test>perl -e"exit 1" && echo succeeded || echo failed failed P:\test>perl -e"exit 0" && echo succeeded || echo failed succeeded P:\test>perl -e"die" && echo succeeded || echo failed Died at -e line 1. failed

You can also group commands

(prog1 && prog1) || (prog3 || prog4)

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!


In reply to Re: batch query - win32 by BrowserUk
in thread batch query - win32 by Anonymous Monk

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.