Calling scripts within script

Hi,

I have written a some six scripts to move large files and re-size them. This has been done step by step, taking backup, creating the new files, merging the files, removing the temporary files created.

Since these files are around 500 MB, each step takes somewhere between 1 to 5 mins.

My question is, If I call these scripts in the order I perform the steps in a script, will the control wait for completion of each script or will it goto the next line and call the next script before the other one is complete.

Is there a better way to check and do this.

Thanks

  1. each script will execute - the calling (main) script will wait until the child script completes - or fails.

  2. your child scripts should return > 0 - 1 is a good choice - on failure, zero on success.

  3. The parent script should check $? (the return code of the child script) after each script completes

#!/bin/sh
# main.sh
for i in $@
do
   $i
   if [[ $? -ne 0 ]] ; then
       echo "script $i failed"
       exit 1
   fi
done

usage example:

main.sh script1.sh script2.sh script3.sh