Re: script calling script - early termination

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 10/04/05


Date: Tue, 4 Oct 2005 11:02:42 -0400

On 2005-10-04, EdStevens wrote:
> A little advice is needed. I've been searching the newsgroups and my
> own bookshelf, and if I've seen the answer I've not recognized it as
> such. Here's the deal:
>
> Given a script, myscript.sh
>
> #!/bin/sh
> my_subscript_a.sh
> my_subscript_b.sh
>
> Where both my_subscript_a.sh and my_subscript_b.sh look something like
> this:
>
> #!/bin/sh
> #-- do some work --
> exit $status
>
> Independently, both subscripts work as advertised. However, when I
> execute the parent, myscript.sh, only the first sub (my_subscript_a.sh)
> actually executes. I'm pretty sure that the final 'exit' statement in
> the subscript is what is short-circuiting things, but I can't touch
> that, so am looking for something I can do in the parent script when I
> call the subscript..

   Why be "pretty sure" when you can be 100% sure, one way or the
   other, by testing the scripts with the exit statement commented
   out?

   Have you checked the return code of the subscript?

   Do you have "set -e" in your parent script?

-- 
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>


Relevant Pages

  • Re: script calling script - early termination
    ... > own bookshelf, and if I've seen the answer I've not recognized it as ... Should certainly be "exit $?" ... > the subscript is what is short-circuiting things, ... so am looking for something I can do in the parent script when I ...
    (comp.unix.shell)
  • Re: script calling script - early termination
    ... >> own bookshelf, and if I've seen the answer I've not recognized it as ... >> exit $status ... so am looking for something I can do in the parent script when I ... subscript unless it exits with status 0. ...
    (comp.unix.shell)
  • Re: obshell.run hangs (2)
    ... >>>main script runs a loop that just launches each sub process at a certain ... The SUBscript is being launched ... > from the MAINscript which is in a continuous loop firing off the ... MAINscript to wait for each one to complete before launching a different ...
    (microsoft.public.scripting.wsh)
  • Re: Changing a users password non-interactively?
    ... You need expect and a setpass.expect script which ill add ... exit with a nasty warning. ... # Be careful of the COMMAND and UNDOCMD - they are dependant on your ...
    (comp.unix.aix)
  • Re: script does not always work the same each time.
    ... I have written a simple script to test code build and test run on a ... $lineterminationChar {append output $expect_out; ... exit 1;} ...
    (comp.lang.tcl)

Loading