- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: su -c within a script
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
04-07-2005 02:40 AM
04-07-2005 02:40 AM
I have a user who needs to su to another userid to run a command within a script. However, the user is non-root and therefore, a password is required. The problem is that su will not run from a script because it is interactive and therefore you have to physically type the password. I was thinking of SUDO, but they don't need to run the program as root. Any ideas?
BTW, this is required because the user needs to change to the other userid to run the file because of the profile.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2005 02:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2005 02:53 AM
04-07-2005 02:53 AM
Re: su -c within a script
What is the issue with sudo. You are not executing your program as root. If you do sudo su - user2 -c "program" your effective user id is user2 not root.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2005 02:55 AM
04-07-2005 02:55 AM
Re: su -c within a script
You will need to look at sudo to handle your requirement as written without being prompted for a password.
It is possible to hardcode passwords into scripts, but thats a very bad idea from th security standpoint.
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
04-07-2005 03:02 AM
04-07-2005 03:02 AM
Re: su -c within a script
Get it here - http://hpux.connect.org.uk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2005 04:57 AM
04-07-2005 04:57 AM
Re: su -c within a script
if you need just entries out of the environment of that other user, these should be transferred to a seperate script (e.g. set.env). Then they can be sourced by every user who needs them (". set.env" for Bourne-like or "source set.env" for CSH-like Shells).
If there are other reason to switch to another user from a non-root account, you can try to replace the 'su' by 'rsh localhost' or 'ssh localhost'. These commands can easily be setup to lack the need of entering a password.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2005 05:52 AM
04-07-2005 05:52 AM