shell script to trigger an other shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers shell script to trigger an other shell script
# 1  
Old 11-06-2011
shell script to trigger an other shell script

Folks,
how to trigger a shell script eg " B " from shell script eg "A" and parse different arguments to the child shell script "B" - like 0 the first time the shell script "B" is triggered and 1 the next time.


Shell script A -----------> launch shell script B with an args 0 --------> done

The next time Shell Script A is launched--------------> Launch shell script B with an args 1 -----------------------> done


Thanks for your help

Ven
# 2  
Old 11-06-2011
You can save the argument which is being passed to script B in a file everytime script A gets executed.

Here is an example.

Code:
 
Script A
 
LOC="Where you want to save the argument counter file"
ARG_CNT_FILE="Name of file"
if [ ! -f ${LOC}/${ARG_CNT_FILE} ] ## Checking for the existance of FILE
then
ARG_CNT=0 ## since the FILE doesn't exist, hence 1st time execution
else
ARG_CNT=`cat ${LOC}/${ARG_CNT_FILE}` ## FILE exists get the argument value from the FILE
ARG_CNT=`expr ${ARG_CNT} + 1` ## Increment the counter by 1
fi
echo ${ARG_CNT} > ${LOC}/${ARG_CNT_FILE} ## Save the new value of counter to the FILE
SCRIPT_B ${ARG_CNT} ## Execute script B with the argument

Regards,
Vishal
This User Gave Thanks to vishalaswani For This Post:
# 3  
Old 11-07-2011
stop the B script when arg is 1

Hello Vishal,
Thanks for you reply , i have one more question that i think you can answer, how to detect if the script B is running and stop the script B immediately in the middle and exit out of the program.

Thank you
venu
# 4  
Old 11-07-2011
What does it do? How will it be launched (script A ...) batch/in background?
# 5  
Old 11-07-2011
Script B runs when script A is triggered, and if you want to put the stopping feature in the code then you need to first decide the condition when you want to stop B.

If you can think of such condition then it will be easy.

Regards,
Vishal
# 6  
Old 11-07-2011
Script A is launched by Task scheduler on windows.

Once script A is launched, it will write a 0 in to the args file, and parse the 0 to the script B, script B detects that it received an yes flag to go ahead and do whatever it wants to do.

else
if script B receives an argument of 1 and has already been executing then it should stop doing what ever it is doing and quit or if it is starting a fresh cycle to execute then it should stop and quit as it is

Basically i need something like a switch to stop the script B from executing again if it has been already executed once.
or if scriptB is in process of process of doing what it is supposed to then i want it to stop as it is at that point and exit out of the program.


Thanks to Vishal and VBE for their valuable suggestions

Venu
# 7  
Old 11-08-2011
after passing argument 1 to the file , how about getting the pid and killing the script B

i am not sure whether this works as you are specifying windows system but its possible to get the pid and for any process running using

Code:
ps -ef | grep "scriptb"

later taking the $2 using awk and passing kill can stop the script b
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

2. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

4. Shell Programming and Scripting

Shell script trigger using http interface

Hi I have created a shell program, which takes a series of parameters as shown in the below code. Its working good from terminal. My program restorejob.sh -g <NAME> -p <Path-to-search> -r <Path-to-restore> Its working fine from bash shell. I want to extend this functionality like... (1 Reply)
Discussion started by: rakeshkumar
1 Replies

5. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

6. Shell Programming and Scripting

Execute shell script from plsql trigger

Hi, I have been assigned a job which requires me to send mails from unix(Mailx) upon on certain actions triggered in the database. On insert/update of a certain field into one of the database tables the shell script present in Unix box responsible to send mail though mailx needs to be triggered... (7 Replies)
Discussion started by: hemant.bs11
7 Replies

7. Shell Programming and Scripting

How to trigger workflow manager through shell script?

I am new to siebel workflow manager. Can anyone help me regarding the shell script which will trigger siebel workflow manager. I want a sample shell script to trigger workflow manager. Thanks in advance. (2 Replies)
Discussion started by: siri_886
2 Replies

8. UNIX for Dummies Questions & Answers

Can we trigger an shell script on an event

Hi, My program A updates a log called logA. I have a shell script S that is responsible to send emails reading from the log. I want to trigger execution of the script whenever there is an update to the log. Thanks in advance. (8 Replies)
Discussion started by: cv_pan
8 Replies

9. Shell Programming and Scripting

Trigger Shell Script from Current Script

Hello all, I'm new to shell programming and need some help. I would like to set up a step within a shell script to trigger another shell script to run, based on the highest return code generated in the current script. For example, if the highes return code value in the current script is less... (1 Reply)
Discussion started by: mmignot
1 Replies

10. Shell Programming and Scripting

Shell script call from a DB trigger

Has anybody been able to execute a shell script call from a database trigger? If so what are the steps to execute it? Do we have any specific packages in Oracle? Reards, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question