- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to get the correct exit status of a shell
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
Discussions
Discussions
Forums
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
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
тАО05-03-2004 02:11 AM
тАО05-03-2004 02:11 AM
How to get the correct exit status of a shell
I am calling this script a.ksh in another script b.ksh eg.
#script b.ksh
a.ksh
if [ $? -ne 0 ]; then
echo failed
else echo success
fi
My problem is even through a.ksh fails when I call in my my script b.ksh I get $?=0 ( success ).
How do I get the correct exit status?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 02:16 AM
тАО05-03-2004 02:16 AM
Re: How to get the correct exit status of a shell
a.ksh
result=`echo $?`
if [ $result -ne 0 ]
then
echo failed
else
echo success
fi
hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 02:17 AM
тАО05-03-2004 02:17 AM
Re: How to get the correct exit status of a shell
e.g.
exit ${STATUS}
Secondly, you need to immediately capture ${?}. It's best to assign it to a variable because the next shell command will alter ${?}.
a.ksh
STAT=${?}
date # just some dummy commands to illustrate
ls # my point
if [ ${STAT} -eq 0 ]
then
echo "Ok"
else
echo "a.ksh failed; status ${STAT}"
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 03:01 AM
тАО05-03-2004 03:01 AM
Re: How to get the correct exit status of a shell
Can you please also tell me in UNIX how do I comment multiple lines.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 03:03 AM
тАО05-03-2004 03:03 AM
Re: How to get the correct exit status of a shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 03:19 AM
тАО05-03-2004 03:19 AM
Re: How to get the correct exit status of a shell
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 03:24 AM
тАО05-03-2004 03:24 AM
Re: How to get the correct exit status of a shell
go to the command mode by hitting esc
type the following command
:1,30s/^/#/
then hit enter
you will see # marks appear as the first character in first 30 lines of your file
don't forget to save your file before exiting
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 03:26 AM
тАО05-03-2004 03:26 AM
Re: How to get the correct exit status of a shell
Uou have to use # in the begining for every line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2004 05:45 AM
тАО05-03-2004 05:45 AM
Re: How to get the correct exit status of a shell
while false
do
done
Or any of a various things like this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2004 07:49 AM
тАО05-04-2004 07:49 AM
Re: How to get the correct exit status of a shell
# one line comment
echo start
<<'*/'
a really
long
multiple line
comment
*/
echo finish