- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- su - user -c "script" As root but needs manual ex...
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
12-18-2003 03:02 AM
12-18-2003 03:02 AM
I am testing the script below so that I can put it in rc scripts. It
su - peter
but stops at the command line then when I type
exit the script gets executed:
what is preventing it from su - peter and then
executing /usr/bin/appstart without my intervention.
# ./COG start
$ exit
(script runs now)
============excerpt of the script name:COG===========
#!/sbin/sh
APP_START="/usr/bin/appstart"
APP_ID="peter"
case "$1" in
'start')
if [ -x "$APP_START" ]; then
su - ${APP_ID} -c "$APP_START"
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 03:05 AM
12-18-2003 03:05 AM
Re: su - user -c "script" As root but needs manual exit command to run script
You need as
esac
to terminate the case statement.
Rgds,
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 03:06 AM
12-18-2003 03:06 AM
SolutionDon't use the minus sign with su. Put what ever environment variables are required in the script. You'll have a lot less difficulty with terminal oriented commands interfering with your results.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 03:09 AM
12-18-2003 03:09 AM
Re: su - user -c "script" As root but needs manual exit command to run script
The first is that you are using /sbin/sh instead of /bin/sh. I don't know what the difference is between these two but on my system,they are definately different. Tis may have some kind of impact.
The second thig is that after your "./COG start" which you seem to run as root, you get a "$" prompt back. This would suggest to me that the "su" is actually working but that "appstart" itself has got the problem or possibly peters .profile or /etc/.profile. Instead of typing exit, try "id" and see who you are.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 07:34 AM
12-18-2003 07:34 AM
Re: su - user -c "script" As root but needs manual exit command to run script
Actually, I have esac in the end.just did not paste the bottom of the script. Thanks
Pete,
I took your suggestion and did just that. Now it works. Guess, I was trying for a shortcut.Thanks a lot.
Mark,
The appstart was working fine if I run it as peter. After su, if id shows peter.
Thanks. The easiet way was to hard code the ENV VAR. in the script. The /sbin/sh and /bin/sh does not make a diff in my case.
Thanks to all. Jef, Pet, Mar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2003 07:40 AM
12-18-2003 07:40 AM
Re: su - user -c "script" As root but needs manual exit command to run script
I assume, the case and the rest is just out of post, the script would complain about a nomatch or so.
Hi Mark,
if I am not mistaken then /sbin/sh is linked static and /bin/sh is linked dynamic.
Hi Sam,
I am glad, that it worked out,
be happy,
Michael