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.

Have a shell script call another shell script and exit

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-18-2006
heprox heprox is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 21 March 2007, 11:54 AM EDT
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Unix or Linux Question Have a shell script call another shell script and exit

I have a shell script that calls another shell script "str_process_main" that runs in a loop until a given time. I want the first script to just call the second one and then exit. The first script is:


Code:
#!/bin/ksh
DATE=$(date +%m%d%y)
DPID=$(ps -ef|grep str_process_main|grep -v grep)
if [ "${DPID}" = "" ]; then
   cd /usr/local/wss_polling
   str_process_main
   echo "The process was not running."
else
   echo "The process is already running: $DPID."
fi
exit

The first script just sits there and runs?
Sponsored Links
    #2  
Old Unix and Linux 11-20-2006
dhananjayk dhananjayk is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 22 November 2006, 5:57 AM EST
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
check it

just call the second script as

#!/bin/ksh
DATE=$(date +%m%d%y)
DPID=$(ps -ef|grep str_process_main|grep -v grep)
if [ "${DPID}" = "" ]; then
cd /usr/local/wss_polling
. str_process_main
echo "The process was not running."
else
echo "The process is already running: $DPID."
fi
exit

note that the 2nd script is called using a dot (.)
this dot notation runs the second script in the same shell ..i.e calling shell ..
if u call it without using a dot ...then also the script will run ... but in a new shell ..( sub-shell)
Sponsored Links
    #3  
Old Unix and Linux 11-20-2006
aju_kup aju_kup is offline
Registered User
 
Join Date: Jul 2006
Last Activity: 27 August 2008, 8:01 AM EDT
Posts: 189
Thanks: 0
Thanked 1 Time in 1 Post
run the script with nohup in background

#!/bin/ksh
DATE=$(date +%m%d%y)
DPID=$(ps -ef|grep str_process_main|grep -v grep)
if [ "${DPID}" = "" ]; then
cd /usr/local/wss_polling
nohup str_process_main &
echo "The process was not running."
else
echo "The process is already running: $DPID."
fi
exit
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
how to call a particular function from one shell another shell script ponmuthu Red Hat 2 01-08-2011 05:00 AM
call another shell script and pass parameters to that shell script sunrexstar Shell Programming and Scripting 2 11-29-2010 02:53 PM
shell script to call perl script problems regexnub Shell Programming and Scripting 3 08-24-2010 04:32 AM
How to grep sql error in shell script and exit the script? allinshell99 Shell Programming and Scripting 2 05-27-2010 09:06 PM
To call/execute a shell script from a shell script konark UNIX for Dummies Questions & Answers 1 10-26-2007 05:16 PM



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