- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Passing value to su(switch user) cmd
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp
Knowledge Base
Discussions
Forums
Discussions
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
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
09-07-2008 10:35 PM
09-07-2008 10:35 PM
Passing value to su(switch user) cmd
I want to write one script which change user for me without prompting for any inputs.
*******************************************
changeuser.sh:
echo " user is going to change to rpjms "
su rpjms
echo " User has been chnaged successfully "
********************************************
It should not as for password. I want to pass password in script itself.
Could some one help me to do this?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2008 10:39 PM
09-07-2008 10:39 PM
Re: Passing value to su(switch user) cmd
/bin/su - oracle -c "command value with parameters"
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
09-07-2008 10:49 PM
09-07-2008 10:49 PM
Re: Passing value to su(switch user) cmd
It allows you to run commands as a specific users.
You can also control which commands you're allowed to run as that user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2008 10:52 PM
09-07-2008 10:52 PM
Re: Passing value to su(switch user) cmd
i am not getting. What is meant for oracle and -c.
My user name is rpjms and password is xyz.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2008 10:57 PM
09-07-2008 10:57 PM
Re: Passing value to su(switch user) cmd
configure /etc/sudoers file. either
vi /etc/sudoers OR
visudo
sample:
Host_Alias IS_SAP=suxde03*
# User alias specification
User_Alias UNIX_TEAM=arpdh, neumannl, rau, rojahn, sandchau
Cmnd_Alias SUROOT=/usr/bin/su -, /usr/bin/su - root
UNIX_TEAM IS_SAP=(ALL) NOPASSWD: ALL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2008 11:43 PM
09-07-2008 11:43 PM
Re: Passing value to su(switch user) cmd
What I gave was an example:
su - username -c "command string"
example
su - oracle -c "/sbin/init.d/oracle start"
This command says use the user profile of oracle WITH its environment and use the startup script for oracle (which I wrote) with the start parameter.
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
09-08-2008 02:14 AM
09-08-2008 02:14 AM
Re: Passing value to su(switch user) cmd
Only root can do that. And after the script exits, it's back to the original user.
I suppose your script can use sudo to switch to root and then open another terminal window so you can then be the other user.
(If you don't use sudo, you might be able to use expect and then open another window?)