GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- return $error o exit $error.
Operating System - HP-UX
1847140
Members
6031
Online
110263
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 06:33 AM
04-19-2007 06:33 AM
Hi ..
could you let me know how can i use command "return $error o exit $error " into a shell , korn shell, c shell, etc ..
Please let me know ...
Regards.
could you let me know how can i use command "return $error o exit $error " into a shell , korn shell, c shell, etc ..
Please let me know ...
Regards.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 06:41 AM
04-19-2007 06:41 AM
Solution
Actually I thing that you are talking about scripts , because I have never heard about a command like that.
Into a scrito you can use them, for return values and exit the script with determine exit value.
A little example for that could be the following...
sig = hpuxtobsdsig(SCARG(uap, signo));
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
return (EINVAL);
Marco
Into a scrito you can use them, for return values and exit the script with determine exit value.
A little example for that could be the following...
sig = hpuxtobsdsig(SCARG(uap, signo));
if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
return (EINVAL);
Marco
Just unplug and plug in again ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 07:02 AM
04-19-2007 07:02 AM
Re: return $error o exit $error.
Hi Manuales:
One uses 'return' with functions (subroutines) to exit the function or subroutine and provide a return value to the point where the function was called.
One uses 'exit' to immediately stop execution of a process and provide a return value to the caller. In the case of a script, the shell (parent) can interrogate the return code as the caller.
In general, a return code of zero (0) means success and non-zero means failure.
You can use 'return' and 'exit' like this Posix shell:
# cat ./mysh
#!/usr/bin/sh
function I_am_Good
{
return 0
}
function I_am_Bad
{
return 1
}
I_am_Good
RVAL=$?
[ "${RVAL}" = 0 ] && echo "Good is OK" || echo "Good Failed to be good"
I_am_Bad
RVAL=$?
[ "${RVAL}" = 0 ] && echo "Bad is OK" || echo "Bad Failed to be good"
exit 0
...run as:
# ./mysh; echo $?
The return code seen in your shell is zero (0) since the last statement as 'exit 0'.
By the way, you never evaluated responses to your questions here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1115971
Regards!
...JRF...
One uses 'return' with functions (subroutines) to exit the function or subroutine and provide a return value to the point where the function was called.
One uses 'exit' to immediately stop execution of a process and provide a return value to the caller. In the case of a script, the shell (parent) can interrogate the return code as the caller.
In general, a return code of zero (0) means success and non-zero means failure.
You can use 'return' and 'exit' like this Posix shell:
# cat ./mysh
#!/usr/bin/sh
function I_am_Good
{
return 0
}
function I_am_Bad
{
return 1
}
I_am_Good
RVAL=$?
[ "${RVAL}" = 0 ] && echo "Good is OK" || echo "Good Failed to be good"
I_am_Bad
RVAL=$?
[ "${RVAL}" = 0 ] && echo "Bad is OK" || echo "Bad Failed to be good"
exit 0
...run as:
# ./mysh; echo $?
The return code seen in your shell is zero (0) since the last statement as 'exit 0'.
By the way, you never evaluated responses to your questions here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1115971
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 07:22 AM
04-19-2007 07:22 AM
Re: return $error o exit $error.
When called from the main body of a shell script, return and exit have the same effect -- they both exit the shell. When return is called from within a shell function, the function itself is exited but the calling shell continues to execute. On the contrary, when exit is called from withing a function or anywhere else with a script, the script terminates immediately. The exit status of the function or process is the value of the argument given to return or exit.
This really holds true for all shells, Perl, or C/C++ code.
By convention, an exit of 0 indicates success and any other value indicates failure. Also, by convention, you should make an effort to return the value that corresponds to what errno would have been set to had this been a system call. However, the actual exit status of a process or the return value of a function or subroutines means no more and no less than what the programmer/developer intended it to mean.
This really holds true for all shells, Perl, or C/C++ code.
By convention, an exit of 0 indicates success and any other value indicates failure. Also, by convention, you should make an effort to return the value that corresponds to what errno would have been set to had this been a system call. However, the actual exit status of a process or the return value of a function or subroutines means no more and no less than what the programmer/developer intended it to mean.
If it ain't broke, I can fix that.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP