- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Run a command as another user??? please help
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
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
тАО08-02-2006 06:46 AM
тАО08-02-2006 06:46 AM
Run a command as another user??? please help
but when i switch user the script stop unless i type exit to go back in root mode
All i want is to run that sort of script but the script stop after the su - oraweb goes in... won't do anything unless i do exit manualy
#!/bin/sh
su - oraweb
owsctl stop
owsctl stop -nodemgr
exit
kill -9 `pgrep oraweb`
su - oraweb
owsctl start -nodemgr &
owsctl start
Any help is apreciated thanks alot
-mIKE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2006 06:48 AM
тАО08-02-2006 06:48 AM
Re: Run a command as another user??? please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2006 06:51 AM
тАО08-02-2006 06:51 AM
Re: Run a command as another user??? please help
su - oracle -c "command"
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2006 06:53 AM
тАО08-02-2006 06:53 AM
Re: Run a command as another user??? please help
If you really must run this script as different user instead of as oraweb, then I would recommended saving:
#!/bin/sh
owsctl stop
owsctl stop -nodemgr
exit 0
and:
#!/bin/sh
owsctl start -nodemgr &
owsctl start
exit 0
as scripts, say /scripts/a.sh and /scripts/b.sh.
You may then run these scripts like this:
#!/bin/sh
su - oraweb -c "/scripts/a.sh"
kill -9 `pgrep oraweb`
su - oraweb -c "/scripts/b.sh"
exit 0
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2006 06:53 AM
тАО08-02-2006 06:53 AM
Re: Run a command as another user??? please help
or in this case su - oraweb -c "owsctl stop"
consider making the series of commands a script and calling the script via the su command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-02-2006 06:58 AM
тАО08-02-2006 06:58 AM
Re: Run a command as another user??? please help
kill -9 `pgrep oraweb`
The correct procedure is to kill -15 ${PID}, kill -1 ${PID}, kill -2 ${PID}, kill -3 ${PID}, kill -11 ${PID}, and finally and only if necessary, kill -9 ${PID} ---- in that order and doing a kill -0 ${PID} between each command and then testing the result; if 0, the process still exists. Doing a kill -9 can leave temporary files, shared memory, and other resources dangling because no cleanup is possible.
Also, pgrep is not a standard command so you may need to craft a substitute.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2006 12:16 AM
тАО08-03-2006 12:16 AM
Re: Run a command as another user??? please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2006 04:26 AM
тАО08-03-2006 04:26 AM
Re: Run a command as another user??? please help
sudo -u username command