- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: $? from su
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
09-10-2003 02:37 AM
09-10-2003 02:37 AM
$? from su
I use a script to start several applications. Each application is started with a different user, using the su -
I would like to get within the main script the exit status of the command used within the su to start the application.
How can I do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 02:43 AM
09-10-2003 02:43 AM
Re: $? from su
su -c "
I'm nowhere near a server so I might have the syntax a bit screwed, but the concept should work. :-)
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 02:46 AM
09-10-2003 02:46 AM
Re: $? from su
su -
Then check the log afterwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 02:50 AM
09-10-2003 02:50 AM
Re: $? from su
su -
[ $? -ne 0 ] && echo bad return status from trying to start application
This will return any bad return status from the start app command back to the su command to so you can check for the value of $? immediately after the su.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 02:55 AM
09-10-2003 02:55 AM
Re: $? from su
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 02:57 AM
09-10-2003 02:57 AM
Re: $? from su
# su oracle -c true
# echo $?
0
# su oracle -c false
# echo $?
1
# su oracle -c "exit 3"
# echo $?
3
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2003 11:53 PM
09-10-2003 11:53 PM
Re: $? from su
In fact the only solution I already found was the temporary file containing the exit status, solution proposed by Stefan. I hoped there was a better solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2003 09:59 AM
09-11-2003 09:59 AM
Re: $? from su
Bill, though I understand what's happening in the case of the PEEK shell, why would su sometimes return the task exit code instead of the command code?
Wouldn't Tim's or Stefan's solution handle that by making the task's exit code be the command's exit code?
Just curious (sorry for the follow-on!).
Regards,
Seth