Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

how to call one script frm another

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 04-14-2008
wrapster wrapster is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 26 January 2011, 9:16 AM EST
Posts: 194
Thanks: 0
Thanked 0 Times in 0 Posts
how to call one script frm another

Hi all,

I would like to know how to call one script from another and the return the value of the called script to the calling script for further processing?(in bash)

This is kinda urgent ,pls assist

Regards
wrapster
Sponsored Links
    #2  
Old Unix and Linux 04-14-2008
mirusnet's Unix or Linux Image
mirusnet mirusnet is offline
Registered User
 
Join Date: Dec 2007
Last Activity: 18 June 2010, 4:33 AM EDT
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts

Code:
. /path/to/your/script.sh

Sponsored Links
    #3  
Old Unix and Linux 04-14-2008
joeyg's Unix or Linux Image
joeyg joeyg is offline Forum Staff  
modérateur
 
Join Date: Dec 2007
Last Activity: 20 May 2015, 10:55 AM EDT
Location: Within two miles of a Dunkin donuts.
Posts: 2,354
Thanks: 84
Thanked 162 Times in 148 Posts
Hammer & Screwdriver Calling is easy, returning info more complicated

To call a script, simply issue the command as you would type it at the normal prompt.


Code:
#script one
echo "hello"
#call second script
good_day
#say good-bye
echo "good-bye"
exit

#script good_day
echo "good day to you"
exit 0

The above are simplified, but hopefully show you the simple logic. The last line of 'exit 0' ends the program and returns an error code of 0.
Before my '#say good-bye' line, I could check for a returned value, with somthing like:

Code:
if [ "$?" -ne 0 ]
   then
      echo "A value was returned"
fi

So, you can pass something back as part of the error-handling ability of master programs and called programs.

Otherwise, the only other effective way I know of to pass data from a called program back to the master program is to write the information to a temporary file.
    #4  
Old Unix and Linux 06-08-2009
juliyp juliyp is offline
Registered User
 
Join Date: Jun 2009
Last Activity: 9 June 2009, 12:07 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Hi,
I need to rin few other scripts from one main (mather) script. Working in ksh on LINUX. The only one condition - it should be run in parallel.
I mean I have to be able to call 20 scripts from this mather script in parallel (start them in the same time). Does somebody know how to do it?

Thanks,
Juliy
Sponsored Links
    #5  
Old Unix and Linux 06-08-2009
vidyadhar85's Unix or Linux Image
vidyadhar85 vidyadhar85 is offline Forum Advisor  
The Tutor
 
Join Date: Jun 2008
Last Activity: 17 April 2015, 12:45 AM EDT
Location: INDIA, Bangalore
Posts: 2,049
Thanks: 16
Thanked 106 Times in 102 Posts
Quote:
Originally Posted by juliyp View Post
Hi,
I need to rin few other scripts from one main (mather) script. Working in ksh on LINUX. The only one condition - it should be run in parallel.
I mean I have to be able to call 20 scripts from this mather script in parallel (start them in the same time). Does somebody know how to do it?

Thanks,
Juliy
call each script one by one and run them in background
scr1 &
scr2 &
scr3 &
.
.
.
scr20 &
Sponsored Links
Closed Linux or Unix Question

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
Running a script in system() call and want the script's output amio Shell Programming and Scripting 9 09-13-2010 02:02 AM
how to run script? call other script? su to another user? make a cron? instant000 Shell Programming and Scripting 15 11-23-2009 04:01 PM
call shell script from perl cgi script problem raksha.s Shell Programming and Scripting 2 03-25-2009 04:50 AM
Call a perl script inside a shell script chriss_58 Shell Programming and Scripting 3 12-01-2008 03:28 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 10:15 AM



All times are GMT -4. The time now is 07:10 AM.