- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to login with other userid from 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
12-28-2007 07:05 AM
12-28-2007 07:05 AM
I need to change some things from a script but using other userid, how do i have to program that? i mean, how do i have to use "su -" command to login with the other user and after exit that user?
thanks in advance.
Thanks and Regards :0)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:09 AM
12-28-2007 07:09 AM
Solutionhttp://hpux.its.tudelft.nl/hppd/hpux/Tcl/expect-5.43/
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:21 AM
12-28-2007 07:21 AM
Re: How to login with other userid from a script ...
su -
where command is the script you need to run to "change some things"
as noted, unless you are root when the above is issued, you'll get prompted for the password so you may need expect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:22 AM
12-28-2007 07:22 AM
Re: How to login with other userid from a script ...
i need to know what is the sintax of the command "su" to use it into a script using ksh .....
su - user1 - pass??
please let me know.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:23 AM
12-28-2007 07:23 AM
Re: How to login with other userid from a script ...
that is i want.. but ..
my userid is not root, then, where do i have put the password??? that has to be in automatical way .... with out put the password manually
please let me know ...
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:27 AM
12-28-2007 07:27 AM
Re: How to login with other userid from a script ...
an appropriate sudo rule could do.
If it is a command run from a remote host
creating an ssh RSA key on executing host and appending it to the user's authorized_keys file under which the script should run could be an option.
You can limit the use of the key by prepending a cmd="/path/to/script" option stanza to the key entry in authorized_keys.
Then setting an empty passphrase on ssh-keygen generation is half-way secure (otherwise with passphrase make use of ssh-agent).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:37 AM
12-28-2007 07:37 AM
Re: How to login with other userid from a script ...
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:45 AM
12-28-2007 07:45 AM
Re: How to login with other userid from a script ...
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:45 AM
12-28-2007 07:45 AM
Re: How to login with other userid from a script ...
> my userid is not root, then, where do i have put the password??? that has to be in automatical way .... with out put the password manually
Your script will prompt you interactively for the password when 'su' executes. You cannot place the password in a file and redirect it as STDIN to 'su' either. As noted, 'expect' is an option.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:48 AM
12-28-2007 07:48 AM
Re: How to login with other userid from a script ...
there isn't any
"su - user1 - pass??"
"expect" scripting can handle this, as it can be programmed to react to prompts on the screen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 08:18 AM
12-28-2007 08:18 AM
Re: How to login with other userid from a script ...
user to be used: "special"
my user: myuser
1.- i access to "special" user id home and i created the file .rhosts and this user gave permissions to "muyuser" id to access as follows:
serverdns.company.com myuser
2.- i run the following:
/usr/bin/remsh ipaddress_serverdns -l myuser -n /home/scripts/test_command
AND WORKED !!!!
Thanks all for your help !!!
Have nice day!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 08:19 AM
12-28-2007 08:19 AM
Re: How to login with other userid from a script ...
this script is run into the same serverdns ...
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 08:26 AM
12-28-2007 08:26 AM
Re: How to login with other userid from a script ...
Well done workaround, though!
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 08:45 AM
12-28-2007 08:45 AM
Re: How to login with other userid from a script ...
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 09:24 AM
12-28-2007 09:24 AM
Re: How to login with other userid from a script ...
/usr/bin/remsh ipaddress_serverdns -l myuser -n /home/scripts/test_command"
and it ran as "myuser"....not "special" as you logged in as yourself (if the above is indeed correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 11:00 AM
12-28-2007 11:00 AM
Re: How to login with other userid from a script ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 11:16 AM
12-28-2007 11:16 AM
Re: How to login with other userid from a script ...
Other than your remsh solution, you could just set it up to use cron, if you can schedule your execution.