- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script with different user
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
тАО08-05-2006 05:05 AM
тАО08-05-2006 05:05 AM
Script with different user
- Tags:
- su
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2006 05:25 AM
тАО08-05-2006 05:25 AM
Re: Script with different user
# visudo
dpuser ALL = (prdadm) NOPASSWD: /usr/../stopsap
Then, dpuser can run:
sudo -u prdadm -H /usr/../stopsap. In this way, the dpuser will run the script as prdadm
- Tags:
- sudo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2006 06:02 AM
тАО08-05-2006 06:02 AM
Re: Script with different user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2006 07:22 AM
тАО08-05-2006 07:22 AM
Re: Script with different user
If you are doing it from the root id:
su - prdadm -c "/usr/.../stopsap
If you want to do it from another id, the you will have to use sudo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-05-2006 07:53 AM
тАО08-05-2006 07:53 AM
Re: Script with different user
su - prdadm -c '...' but it always hangs before the user logs in and i need to press enter so that it will enter and do its job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2006 01:00 PM
тАО08-06-2006 01:00 PM
Re: Script with different user
1) Surround all of these commands in .profile with:
if [ -t 0 ]
then
tput ..
tabs ..
fi
2) better:
Create a file that sets and exports any needed environment variables e.g. /usr/local/bin/prdadm_env.sh
and let both your su'ed script AND prdadm's .profile source this file using the "." dot operator.
e.g. . /usr/local/bin/prdadm_env.sh
This sourced file should not contain any exit or return statement because this file becomes part of the foreground process rather than a child process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2006 09:58 AM
тАО08-07-2006 09:58 AM
Re: Script with different user
Can you redirect stdin to /dev/null so it won't bother reading?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2006 09:52 PM
тАО08-07-2006 09:52 PM