Help with EXIT command inside if


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with EXIT command inside if
# 1  
Old 03-21-2009
Help with EXIT command inside if

Hi All,

I want to use EXIT command in a particular scenario.
In my script,its like that:-
if($vairable -eq 1);then
do this thing
do this
do this
fi

if($var2 -eq 1);then
do this
do this
fi

like this there are three four if conditions.
now I want is that if second condition is met then dont go ahead n exit here only else continue with the rest of code.

Kindly suggest me what can be done.

Thanks in advance.
Arun
# 2  
Old 03-21-2009
hey...........can nyone plz help me regarding abv mentionde query...........
# 3  
Old 03-21-2009
Hi,
Why dont you use "CASE" statement instead of "IF". The case statement is always preferred when there are many items to select from instead of using a large if/elif/else statement. It is usually used to implement menus in a script.

Check once if it suits your requirement.

Thanks,
amit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exit Status of Command

Hi All, I am doing an export and import (datapump) of 4 schema. I know we can do an export of 4 schema in one command. But just want to know how to check the exit status if i do the export/import of 4 schema in different commands in background. Please suggest. Thanks, Mani (1 Reply)
Discussion started by: pvmanikandan
1 Replies

2. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

3. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

4. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

5. UNIX for Dummies Questions & Answers

Problem with exit command

Problem with exit command ----------------------------------------------------------------------- Hi, I am executing script written by other user. I am executing script A.ksh, and A.ksh calls B.ksh. But It is giving error: /home/user/B.ksh: exit: -1: unknown option When I checked... (3 Replies)
Discussion started by: shreyas
3 Replies

6. UNIX for Dummies Questions & Answers

Exit out of the Script Command inside a Script

I'm new to Linux. I have a bash script that invokes an executable. I'd like use the SCRIPT command inside the script and exit out of the script command after it writes to the file. Does this make sense? Below is an example of the contents of my script. #BEGIN SCRIPT script typescript... (6 Replies)
Discussion started by: jmungai
6 Replies

7. Shell Programming and Scripting

Exit statement ignored inside KSH function

Hi All, I have multiple functions in my script and I'm trying to capture stdout from some of them, but I also do some error checking in them (in the functions that output something to their stdout that needs capturing) and I need to be able to end the entire script with an error message. ... (2 Replies)
Discussion started by: gkubok
2 Replies

8. Shell Programming and Scripting

command to exit xwindow

What is the command to exit xwindow when i am in xwindow's terminal. Thanks in advance. (3 Replies)
Discussion started by: uativan
3 Replies

9. Programming

Usage of exit() inside a signal handler

Is it ok to use exit() inside a signal handler? I catch SIGUSR1 in a signal handler and I try to close a file and then exit. The result is inconsistent. Sometimes the process exit and sometimes it returns to the original state before the signal handler was invoked. Perhaps exit is not legal in... (8 Replies)
Discussion started by: Tuvia
8 Replies

10. UNIX for Dummies Questions & Answers

exit command

Hi All, Having just started using Unix after a long time on VMS, I end up having multiple Unix and VMS sessions open. Is there a way I can set up a symbol or something so that "lo" means "exit" and exits my session ? On VMS, if I wanted to do the opposite of this I would do it like this : ... (3 Replies)
Discussion started by: cdines
3 Replies
Login or Register to Ask a Question