Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

How to call exeute multiple bash shells from one master shell?

Shell Programming and Scripting


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-10-2018   -   Original Discussion by cplusplus1
cplusplus1's Unix or Linux Image
cplusplus1 cplusplus1 is offline
Registered User
 
Join Date: Apr 2016
Last Activity: 9 May 2018, 1:38 PM EDT
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
How to call exeute multiple bash shells from one master shell?

I have few bash shells, which i want to run sequentially,

how to create a shell file, and execute/call one after other shell file. I am very new to shell programming. Bult some and running individually and also with crontab scheduler.

never had a shell calling other shells, kindly would like to know.

./master_shell.sh (this will be the master shell file)
./shell1.sh
./shell2.sh
so on so forth upto 8 shells.

Thanks a lot for the helpful info.
Sponsored Links
    #2  
Old Unix and Linux 04-10-2018   -   Original Discussion by cplusplus1
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 May 2018, 1:15 PM EDT
Location: Aachen, Germany
Posts: 12,741
Thanks: 414
Thanked 3,916 Times in 3,601 Posts
Well, yes, list the shell scripts, preferably with absolute paths, one after the other in the master script to have them executed sequentially. Make sure you set permissions correctly. If unsure, make up a few simple test scripts and test your setup, e.g. with the -vx options set.
Sponsored Links
    #3  
Old Unix and Linux 04-10-2018   -   Original Discussion by cplusplus1
Chubler_XL's Unix or Linux Image
Chubler_XL Chubler_XL is offline Forum Staff  
Moderator
 
Join Date: Oct 2010
Last Activity: 22 May 2018, 7:27 PM EDT
Posts: 3,527
Thanks: 154
Thanked 1,258 Times in 1,152 Posts
In it's simplest form you would put one script after the other, it's best to use full paths to avoid the script failing if you aren't in the correct directory eg:

master_shell.sh

Code:
#!/bin/sh

/usr/local/bin/shell1.sh
/usr/local/bin/shell2.sh
/usr/local/bin/shell3.sh

However typically you would want to check the exit status of each script and take appropriate action if this fails perhaps something like this:


Code:
#!/bin/sh

/usr/local/bin/shell1.sh
if [ $? -ne 0 ]
then
     echo "Shell1.sh failed exit status was: $?" >&2
     echo "script terminated" >&2
     exit 1
fi

/usr/local/bin/shell2.sh
...

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to call Oracle function with multiple arguments from shell script? Balraj Shell Programming and Scripting 2 08-29-2016 02:28 AM
How can I replicate master master and master master MySQL databse replication and HA? Palak Sharma UNIX Desktop Questions & Answers 0 05-15-2014 01:15 AM
How to call multiple variables in bash !! gnanasekar_beem Shell Programming and Scripting 3 03-18-2011 01:51 AM
Shell script to call multiple java commands vivekdn Shell Programming and Scripting 4 09-03-2008 12:28 AM
BSD, Bash and Shells? RedVenim BSD 3 10-16-2003 09:59 AM



All times are GMT -4. The time now is 02:11 PM.