- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Run a command as user without password
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-13-2005 03:44 AM
04-13-2005 03:44 AM
One of my users (USER1) needs to run a command that belongs to USER2. The problem is that before the command is run, the profile for USER2 has to be run. I realize that su - USER2 -c "command" could work, but it is being run from a batch file and therefore prompting for a password is no good. "su" doesn't seem to have a switch to hard code the password. On the other hand SUDO will run the command with the -S switch allowing for the password, but SUDO will not run the .profile of USER2 and I read in another forum that it is not possible either with SUDO. So any ideas on how I can run the profile of USER2, run the command, and pass the password in a batch file?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 03:46 AM
04-13-2005 03:46 AM
SolutionIts obvious why you don't want to use root.
The other solution is to take the command that user2 owns and put it in a common area like /usr/contrib/bin
There permnissions can be set to allow user1 to run the 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
04-13-2005 03:49 AM
04-13-2005 03:49 AM
Re: Run a command as user without password
user2's profile
user2 command
Call it xxx, run this xx through sudo
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 03:55 AM
04-13-2005 03:55 AM
Re: Run a command as user without password
Here is what i would do. Create a file (e.g. /usr/local/bin/USER2env.sh) that sets and exports any needed environment variables. This file must not contain an exit or return statement. Next, alter USER2's .profile and remove all the environment variables you set in /usr/local/bin/USER2env.sh and insert this single line:
. /usr/local/bin/USER2env.sh
and also insert the same line in your batch script. The "." command sources the file for both USER2's .profile and your command and everyone is happy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2005 07:09 AM
04-13-2005 07:09 AM