Sponsored Content
Full Discussion: exit function doubts
Top Forums Programming exit function doubts Post 302721809 by jim mcnamara on Thursday 25th of October 2012 08:33:00 PM
Old 10-25-2012
Some applications and UNIX code follow the sysexits protocol

For example see:
sysexits(3) - preferable exit codes for programs
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

How to get exit value of an executable that gets called from function?

How to get exit value of an executable that gets called from function? I have an executable called “myexec” which returns 0 on success and different values for different fail scenarios. I need to call this (myexec) executable from “myprog()” function of other executable and get the exit value... (1 Reply)
Discussion started by: sureshreddi_ps
1 Replies

2. Shell Programming and Scripting

exit shell script from function

Hi all, I have tried to put a exit 0 statement within a function I have created in the shell script but it doesn't seem to exit out of the script? Can someone tell me why? And is there any other way to exit out of the script from within a function? Thanks! (1 Reply)
Discussion started by: nvrh7
1 Replies

3. UNIX for Dummies Questions & Answers

EXIT from a Program not from the function..

Hi, I want a command in unix shell script which will exit my whole program, not only from the function it's using. For e.g: $1 == "m_who" && $4 == "Extrnl Vendor" { print "You don have access" exit (0); } If this error is showing on the screen, then nothing should not... (9 Replies)
Discussion started by: ronix007
9 Replies

4. Programming

capturing enter and exit of every function

If I have a "Hello World" function (just prints that) and a similar "Goodbye World" function... is there a way (maybe a compiler option?) that I can get them to be executed directly as the absolute first and last things run in every function call. So for example, the following code: int foo()... (5 Replies)
Discussion started by: jjinno
5 Replies

5. Shell Programming and Scripting

exit from function

Hi all, My kshell code is not working, when I use a function to return something. But when I use the same function as without returning any values, it is working. Pls help me here. Code1 : func1 () { y=`echo $x | grep XXX| cut -f 2 -d ' '` if ; then exit 100 ... (2 Replies)
Discussion started by: poova
2 Replies

6. Shell Programming and Scripting

Exit from function

Hi, I just want to exit from function if some condition doesnt meet then control should go back to main program and start running from where it left.. When i used "exit" inside the function, its simply exited from entire script and it didnt run anymore.. Any idea how to do this.. Thanks... (3 Replies)
Discussion started by: nram_krishna@ya
3 Replies

7. UNIX for Advanced & Expert Users

Cannot exit from a function?

Hi, Is there a way to exit from a subcommand, which is a function in my example below? #!/bin/ksh function exitFunction { if ]; then echo "success" elif ]; then echo "failed" exit 1 # the exit problem fi exit 0 } ... (2 Replies)
Discussion started by: chstr_14
2 Replies

8. Shell Programming and Scripting

After exit from function it should not call other function

Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this? iNOUT i AM GIVING TO THE... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

9. Shell Programming and Scripting

Replacement of exit function

I am reading multiple numbers from user and getting its respective string value from the One.txt.But while putting this text value to the two.txt file , i want to check that if this string already there in the file , if the string already exists in the two.txt file .....the string will be ignored.... (1 Reply)
Discussion started by: jalpasoni
1 Replies

10. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
SYSEXITS(3)						   BSD Library Functions Manual 					       SYSEXITS(3)

NAME
sysexits -- preferable exit codes for programs SYNOPSIS
#include <sysexits.h> DESCRIPTION
According to style(9), it is not a good practice to call exit(3) with arbitrary values to indicate a failure condition when ending a program. Instead, the pre-defined exit codes from sysexits should be used, so the caller of the process can get a rough estimation about the failure class without looking up the source code. The successful exit is always indicated by a status of 0, or EX_OK. Error numbers begin at EX__BASE to reduce the possibility of clashing with other exit statuses that random programs may already return. The meaning of the codes is approximately as follows: EX_USAGE (64) The command was used incorrectly, e.g., with the wrong number of arguments, a bad flag, a bad syntax in a parameter, or whatever. EX_DATAERR (65) The input data was incorrect in some way. This should only be used for user's data and not system files. EX_NOINPUT (66) An input file (not a system file) did not exist or was not readable. This could also include errors like ``No message'' to a mailer (if it cared to catch it). EX_NOUSER (67) The user specified did not exist. This might be used for mail addresses or remote logins. EX_NOHOST (68) The host specified did not exist. This is used in mail addresses or network requests. EX_UNAVAILABLE (69) A service is unavailable. This can occur if a support program or file does not exist. This can also be used as a catchall message when something you wanted to do doesn't work, but you don't know why. EX_SOFTWARE (70) An internal software error has been detected. This should be limited to non-operating system related errors as possi- ble. EX_OSERR (71) An operating system error has been detected. This is intended to be used for such things as ``cannot fork'', ``cannot create pipe'', or the like. It includes things like getuid returning a user that does not exist in the passwd file. EX_OSFILE (72) Some system file (e.g., /etc/passwd, /var/run/utmp, etc.) does not exist, cannot be opened, or has some sort of error (e.g., syntax error). EX_CANTCREAT (73) A (user specified) output file cannot be created. EX_IOERR (74) An error occurred while doing I/O on some file. EX_TEMPFAIL (75) Temporary failure, indicating something that is not really an error. In sendmail, this means that a mailer (e.g.) could not create a connection, and the request should be reattempted later. EX_PROTOCOL (76) The remote system returned something that was ``not possible'' during a protocol exchange. EX_NOPERM (77) You did not have sufficient permission to perform the operation. This is not intended for file system problems, which should use EX_NOINPUT or EX_CANTCREAT, but rather for higher level permissions. EX_CONFIG (78) Something was found in an unconfigured or misconfigured state. The numerical values corresponding to the symbolical ones are given in parenthesis for easy reference. SEE ALSO
exit(3), style(9) HISTORY
The sysexits file appeared somewhere after 4.3BSD. AUTHORS
This man page has been written by Jorg Wunsch after the comments in <sysexits.h>. BUGS
The choice of an appropriate exit value is often ambiguous. BSD
March 31, 1996 BSD
All times are GMT -4. The time now is 09:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy