- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Return Codes -Shell Scripts -HP-UX
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
06-01-2000 06:56 AM
06-01-2000 06:56 AM
Return Codes -Shell Scripts -HP-UX
Has anyone run across this? I have a scriptA
which calls scriptB. If scriptB returns a status code of 0, no problem, execution continues with subsequent statements in scriptA.
However, if scriptB returns abnormal termination (anything other than zero, eg even exiting with "exit 1"), everything stops, subsequent statements in scriptB are
not executed.
What I want to do in scriptA is to check the
status code returned, and execute appropriate
logic.
I'm wondering, does a profile parameter need to be changed? Shell problem? HP-UX bug?
Thanx in advance to whoever can help.
Vince Idone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2000 07:11 AM
06-01-2000 07:11 AM
Re: Return Codes -Shell Scripts -HP-UX
Basically, when B has finished, and returns control to A, you can check the return value from B, by doing a test on the value supplied by $?.
The problem is that you may want to have differing return values, and the best way to do this is to change script B to test at various stages, and depending on whether that stage has been succesfull, set the exit code to a value for that specific stage;
eg:
A calls B
B starts to run, does abc, test if ok, if yes continue, else exit 2
assming ok, next stage in B, test for correct result, ok then continue, or if not exit 3.
In A you would then have something like a case statement that tests $?, and does:
value 2) means erro x
value 3) means error y
and so on.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2000 07:23 AM
06-01-2000 07:23 AM
Re: Return Codes -Shell Scripts -HP-UX
set -e
somewhere or you invoked the shell like:
#! /usr/bin/ksh -e
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2000 01:40 AM
06-05-2000 01:40 AM
Re: Return Codes -Shell Scripts -HP-UX
I got following problem a couple of days ago: scriptA sources scriptB (scriptA contains a line such as . scriptB). In scriptB if an error is detected, I used "exit 1" statements.
Bad idea, since "exit" ends the current process... and sourcing a script uses the SAME process for BOTH scripts, thus scriptB stops scriptA. (More funny: if you source scriptB from a remote session, it even closes the remote session!)
Since I replaced all "exit" statements by "return" statements, everything runs fine.
Hope it helps,
Emmanuel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2000 07:19 AM
06-05-2000 07:19 AM
Re: Return Codes -Shell Scripts -HP-UX
if seq_check.scrpt seff50 seff50.dat
then
echo "seq check was successful." else
echo "sequence check Failed!"
fi