- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting $? issue
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-20-2002 06:18 PM
06-20-2002 06:18 PM
However a check within script 1 of $? immidiately after script 2 returns indicates that $? is equal to 1! No processing takes places between the last statement of script 2 and the statement in script 1 immidiately following the call of script 2! How can this be?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2002 06:36 PM
06-20-2002 06:36 PM
Re: Scripting $? issue
XX=`some_cmd`
STAT=$?
you then test the value of ${STAT} rather than $?.
I would make sure that script2 exits with a value - this becomes the exit status that script1 sees (or if a function, returns with a value) so that you are positive that no values are 'floating'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 09:21 AM
06-21-2002 09:21 AM
Re: Scripting $? issue
Is script 2 explicitly terminating by exit 0, or at EOF where $? is that of the last full statement?
Sure the last status in the script may be 0, but what is happening when the script actually terminates? How was it invoked by script 1?
Can we see the appropriate code snippits?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 01:10 PM
06-21-2002 01:10 PM
Re: Scripting $? issue
The main script (script 1) has the following statements,
rc=0
FileCreate
rc=$?
echo $rc
"FileCreate" is a function in another script (script 2) listed below.
FileCreate() {
VgnFileCreate $ARG1 $ARG2
rc=$?
echo $rc
return rc
}
The function VgnFileCreate successfully executes and the assignment rc=$? evaluates to 0 which is displayed by the echo statement.
However when the value of rc is echoed in script 1 after the FileCreate function of script 2 has returned, the value is different (say for example 1)
A point worth noting is that when I remove the return rc statement from the FileCreate function of script 2, rc evaluates correctly (to the value echoed from the function) within script 1! Any ideas on the reason for this anomaly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 01:11 PM
06-21-2002 01:11 PM
Re: Scripting $? issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 01:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2002 01:37 PM
06-21-2002 01:37 PM
Re: Scripting $? issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2002 08:22 AM
06-22-2002 08:22 AM
Re: Scripting $? issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2002 05:30 PM
06-22-2002 05:30 PM
Re: Scripting $? issue
set -x
You'll need to add set -x inside each function too.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2002 06:40 AM
06-24-2002 06:40 AM