how to call one script frm another | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

how to call one script frm another

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 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 04-14-2008
mirusnet's Avatar
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 04-14-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
 
Join Date: Dec 2007
Last Activity: 16 September 2014, 2:22 PM EDT
Location: Out running a Marathon.
Posts: 2,328
Thanks: 72
Thanked 153 Times in 142 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 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 06-08-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Advisor  
The Tutor
 
Join Date: Jun 2008
Last Activity: 9 April 2014, 1:31 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 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
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 05:33 AM.