Calling shell script within shell script | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Calling shell script within shell script

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-26-2013
baanprog baanprog is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 5 March 2014, 10:08 PM EST
Posts: 40
Thanks: 7
Thanked 0 Times in 0 Posts
Calling shell script within shell script

Hi All,

I have a simple script that has 8 more scripts being called within it.
Like below

Main Script.sh has within it like below
-----------------------


Code:
Script1.sh
Script2.sh
Script3.sh
Script4.sh
Script5.sh
Script6.sh
Script7.sh
Script8.sh

-----------------------------

Now I want 2 to run after 1 finishes and 3 after 2 and likewise until 8 as each script create a huge file which can take time to complete and it cannot be a fixed value(so cannot use sleep).

Please let me know will unix automatically wait for script 1 to finish for script 2 to start and so on

or

should I use (& and wait) combination to handle this.

Thanks
Moderator's Comments:
Please use CODE tags when posting code, input, and output samples.

Last edited by Don Cragun; 08-26-2013 at 04:25 AM.. Reason: Add CODE tags.
Sponsored Links
    #2  
Old 08-26-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 28 August 2014, 1:35 AM EDT
Location: San Jose, CA, USA
Posts: 4,463
Thanks: 175
Thanked 1,499 Times in 1,271 Posts
Quote:
Originally Posted by baanprog View Post
Hi All,

I have a simple script that has 8 more scripts being called within it.
Like below

Main Script.sh has within it like below
-----------------------


Code:
Script1.sh
Script2.sh
Script3.sh
Script4.sh
Script5.sh
Script6.sh
Script7.sh
Script8.sh

-----------------------------

Now I want 2 to run after 1 finishes and 3 after 2 and likewise until 8 as each script create a huge file which can take time to complete and it cannot be a fixed value(so cannot use sleep).

Please let me know will unix automatically wait for script 1 to finish for script 2 to start and so on

or

should I use (& and wait) combination to handle this.

Thanks
Your script as written above will not start Script2.sh until Script1.sh exits. As long as Script1.sh doesn't start anything asynchronously that hasn't completed before it exits; you will be fine.
Sponsored Links
    #3  
Old 08-26-2013
baanprog baanprog is offline
Registered User
 
Join Date: Mar 2005
Last Activity: 5 March 2014, 10:08 PM EST
Posts: 40
Thanks: 7
Thanked 0 Times in 0 Posts
Explain what you mean by asynchronously

Can you explain what you mean by asynchronously??
    #4  
Old 08-26-2013
Don Cragun's Avatar
Don Cragun Don Cragun is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 28 August 2014, 1:35 AM EDT
Location: San Jose, CA, USA
Posts: 4,463
Thanks: 175
Thanked 1,499 Times in 1,271 Posts
Quote:
Originally Posted by baanprog View Post
Can you explain what you mean by asynchronously??
Asynchronously means that it contains a command that ends with & and exits without waiting for that command to complete; or calls a program that starts some processing in the background and exits before that background processing completes.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
calling a shell script present on another server using perl script. anandgodse Shell Programming and Scripting 3 07-18-2012 01:24 AM
How we can pass the argument when calling shell script from perl script anuragpgtgerman Shell Programming and Scripting 5 03-21-2012 03:57 PM
Syntax error calling TCL script from shell script marcoss90 Shell Programming and Scripting 1 03-13-2011 09:14 AM
calling 'n' number of shell scripts based on dependency in one shell script. shashi369 Shell Programming and Scripting 1 11-03-2009 04:31 PM
Calling shell functions from another shell script jisha Shell Programming and Scripting 6 04-05-2008 04:29 PM



All times are GMT -4. The time now is 03:05 AM.