Trigger with condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trigger with condition
# 1  
Old 05-31-2009
Trigger with condition

If test.ksh is successful then I have a sequence of script which needs to execute automatically. Is it possible to capture the return code to execute the next script automatically? what is better way of doing this.
# 2  
Old 05-31-2009
check the return code of the script

Code:
if [ $? -eq 0 ]; then
execute the other scripts
else
stop here
fi

-Devaraj Takhellambam
# 3  
Old 05-31-2009
test.ksh is not a single cmd to check previous cmd is executed or not and trigger the remaining script it is about bunch of 100 lines script. Consider test.ksh as a job. If status the job is successful then trigger the other script.
# 4  
Old 05-31-2009
There may be many ways to do it..
Let the first script write a log into a file and when it ends successfully, let it write something like "script successful" or "script failed".

Use a while loop in the other script check the file and see if it has success or failure in the logs. If it greps for a sucess, let it end the loop and start running the rest of the code.
or else exit the script.
# 5  
Old 05-31-2009
I don't know if this works for you but you can try :
Code:
firstscript.sh && secondscript.sh

Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trigger script based on condition

Hi Guys, I am having below code which runs based on condition, Is it possible to check condition at the time of trigger code=$1 if ;then nohup sh script.sh $val 1 & fi I need to trigger if the $code = JP then only to trigger nohup sh script.sh $val 1 & My try but wanted... (4 Replies)
Discussion started by: Master_Mind
4 Replies

2. Shell Programming and Scripting

To trigger script on particular instance

Hi Guys, I have a main_script.sh which runs every day and scheduled in crontab. in the main script i read data from config file test.config apple mango orange main_script.sh for i in `cat test.config` do if then echo 'Apple' (3 Replies)
Discussion started by: Master_Mind
3 Replies

3. Shell Programming and Scripting

Help not trigger the trap

mainpid=$$ (trap "echo timeout" SIGTERM SIGKILL SIGINT; sleep 5; kill $mainpid) & watchdogpid=$! sleep 10 #do something kill $watchdogpid I design a timeout function script I don't see the echo "timeout" is on the screen (1 Reply)
Discussion started by: yanglei_fage
1 Replies

4. Shell Programming and Scripting

Automatic script trigger

Hi, I'm looking for a way to solve the following scenario: A shell should automatically trigger / run when a text file is placed or present at a specific location. My idea - to create a cron / anacron for every minute and inside that i will call a temp script. Temp script will move to my... (9 Replies)
Discussion started by: Gautham
9 Replies

5. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

6. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

7. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

8. HP-UX

Control-M Job trigger

Hi, I'm totally new in Control-M and I really need some help. Here's my problem. I need to make job X from a server trigger job Y from a different server where job X must receive a confirmation first before execution. :confused: I really have no idea on how to do that so can you please give... (1 Reply)
Discussion started by: criphaze22
1 Replies

9. UNIX and Linux Applications

update trigger

hi all, i hope i am posting this /beginner) question in the right forum: i want to create an update trigger, which rolls back a transaction if a record of a table is updated. the table has - amongst others - a field 'statusid' - if a record in this table has the statusid X and it is attempted... (0 Replies)
Discussion started by: kalinkula
0 Replies

10. Shell Programming and Scripting

Trigger Enter

Hello, I need to trigger every time enter has been clicked while some one on terminal i tried to googleit but with out result any idea ?? thanks in advance (3 Replies)
Discussion started by: AYAK
3 Replies
Login or Register to Ask a Question