Stop execution of script if some condition fails


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stop execution of script if some condition fails
# 1  
Old 05-02-2011
Stop execution of script if some condition fails

After my if condtion give rusult true then script should stop execution.

Please advice...Thnaks in advance
# 2  
Old 05-02-2011
Use exit command.

Regards.
Peasant.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Stop script execution, when we encounter error

Team, Im new to shell scripting please help in below issue: Considering scenario i have 1.sql,2.sql,3.sql and 4.sql . If my second script fails my loop should come out and should not execute 3.sql and 4.sql. Here is my code. #! /bin/bash echo "exit" | user/password | grep Connected >... (4 Replies)
Discussion started by: preethi87
4 Replies

2. Shell Programming and Scripting

If condition fails for special charecter

I have a sample server name listed in variable as below: var="server-13" I need to check if the 7th character on $var is number 1 whichenv=`echo "$var"| head -c 7 | tail -c 1` if ]; then echo "9 found" else echo "9 Not Found" fi Output: This works... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. Shell Programming and Scripting

To stop execution in cron

hi guys i have a question my cron should start executing minute but it sould stop execute only i have tried tis 10 * * * * /home/sample.sh >> /data/band/cron_$(date+|%Y|m|d).log (2 Replies)
Discussion started by: azherkn3
2 Replies

4. Shell Programming and Scripting

[Solved] How to stop script at certain condition?

Hi Gurus, my script likes below if ;then if ; then exit 30 fi if for loop do done I want to if condition1 is true, it exit the execution the script completely with error code 30. but right now it still exe for loop. I try to add below if ;then if ; then ... (3 Replies)
Discussion started by: ken6503
3 Replies

5. Shell Programming and Scripting

How to exit from shell script if above condition fails?

HI cd ${back_home} if above back_home does not exist, then script shoul exit. Please let us know how to do that (7 Replies)
Discussion started by: buzzme
7 Replies

6. Shell Programming and Scripting

Script execution fails

hi, i am trying to run this script, getting below error, can some one help me in this Error: -bash: on_failure.sh: line 23: syntax error: unexpected end of file ======================================================== # CHANGE HISTORY # # YYYYMMDD Change by Desription # --------... (2 Replies)
Discussion started by: szs
2 Replies

7. 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

8. Shell Programming and Scripting

how to stop execution of a script after one hour

I have a shell script that writes some data in a file. I want to stop the script after one hour from start of execution using "EXIT 1". how to do it. I don't want to use CRONTAB. (5 Replies)
Discussion started by: mady135
5 Replies

9. AIX

stop execution of script with in the script

Hello i want to incorporate of piece of code in the shell script which checks whether same script is already running or not. If it is already running i want to come out (exit) if its not then continue with the execution of the script. Any help would be very much appreciated Thanks (3 Replies)
Discussion started by: dsdev_123
3 Replies

10. Programming

how to stop execution in for loop

Hi all, I am working on a c source code nearly 2000 line . it contains one big for( i=0; i< 200 ; i++ ) loop of around 600 lines could any tell me how to break the execution of prog when the value of i is 50 in for loop so that i can check inside the loop. Thanks.. (1 Reply)
Discussion started by: useless79
1 Replies
Login or Register to Ask a Question