Sponsored Content
Full Discussion: exiting from script
Top Forums Shell Programming and Scripting exiting from script Post 302340526 by shellwell on Monday 3rd of August 2009 06:13:42 PM
Old 08-03-2009
exiting from script

Hi,

I am trying to exit the script from a function.
I was in assumption that if we use exit ( inside or outside the function) it will exit from the script.

alternatively, return will exit from that particular function.

but in my case, exit is exiting from the function and not the script.

I am using exit in a subfunction.

is there any other way to completly exit from the script at any location?

Thanks.

Last edited by shellwell; 08-03-2009 at 07:17 PM.. Reason: added subfunction part
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exiting from script when error occurs

Hi Friends, Is it possible to exit nicely(ie, to echo a message with the error occurred) from a shell script(quiet a big one :)) once it encounter an error in between the lines? For example, in my script I am calling the command mkdir and sometimes (when the directory already exists) it... (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

2. Shell Programming and Scripting

exiting from script

there are many script in my project.i am having a problem when i am trying to quit from child script.what is the command to wrap up all the parent script and calling script as well? exit 0 is not working.please help.... (1 Reply)
Discussion started by: arghya_owen
1 Replies

3. Shell Programming and Scripting

Script is not exiting from run mode.

Hi Folks. My script is not exiting after run though its working correctly please suggest. #!/bin/ksh trap '' HUP . /bin/functions config_env PATH=/bin:/usr/bin:/usr/local/bin:$EXEC_PATH:$ORACLE_HOME/bin MONTH=$(control_register month) YEAR=$(control_register year) DATE_NOW="Job... (1 Reply)
Discussion started by: Haque123
1 Replies

4. Shell Programming and Scripting

Exiting a script

I have a script abc.sh. Its contents are as follows: (7 Replies)
Discussion started by: lassimanji
7 Replies

5. Shell Programming and Scripting

Bash Script Not Exiting

I have a script planned for the Helpdesk to allow them to (on a couple of RHEL 3 / RHEL 5 servers) reset passwords, stop / start printers, and clear print queues. The appropriate sudo permissions were given to their accounts, and the individual functions all work just fine. The ability to move... (0 Replies)
Discussion started by: tearsong
0 Replies

6. Shell Programming and Scripting

Exiting out of the script

I have to write a script in ksh which again should call another script. Say A.ksh is calling B.ksh. Now in B.ksh if the condition we are checking for is true then we have to go back to the main script A.ksh or if the condition in B.ksh is false then we have to totally come out of the scripts. I... (1 Reply)
Discussion started by: vpv0002
1 Replies

7. Shell Programming and Scripting

Exiting from Minicom on a shell script

This is what I've tried: #!/bin/sh send sh send showifs send exit ! killall minicom My problem is that for some reason when I do this it doesn't give me the results of the prior commands sent like showifs So I suspect my syntax is wrong. (1 Reply)
Discussion started by: uradunce
1 Replies

8. Shell Programming and Scripting

Exiting the script if the character is not recognized

Below is the script that i'm using but i'm getting an error, echo -n "Read the letter >(enter a or b or c) " read letter if || || ; then echo "unacceptable character" else echo "Character Accepted" fi if the character entered is not equal to a or b or c, the script should... (6 Replies)
Discussion started by: web2moha
6 Replies

9. Shell Programming and Scripting

Exiting from the script abruptly

Hi Team, Need your help for the below code snippet. I wrote a module to read the file names remote server using file name convention. Issue : My script is coming out from while loop without reading complete file. test1() { while read line do echo $line file_nm_convention=`echo... (3 Replies)
Discussion started by: gvkumar25
3 Replies

10. Shell Programming and Scripting

Help for exiting the function not script

function2() { cmd1 cmd2 cmd3 .... cmdn } function2() { cmd11 cmd12 cmd13 .... .... } for i in {1,2} (7 Replies)
Discussion started by: yanglei_fage
7 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 04:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy