- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to switch user by 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
11-29-2002 09:23 AM
11-29-2002 09:23 AM
How to switch user by script?
I'm needing to do a script to switch user during a session without inform a password.
I've already tried to use expect, but there's a problem:
I don't get work interactive in new passord, because expect nedd a answer for each action.
Example:
$ expect
expect1.1> spawn su - i67844
spawn su - i67844
17383
expect1.2> expect "Password:"
Password: expect1.3> send "nova2002\r"
expect1.3> exit
So, when i go out of expect, I don't get to switch user.
I hope that you understand me.
Thank you!!!
Periandro Saraiva Vaz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2002 09:36 AM
11-29-2002 09:36 AM
Re: How to switch user by script?
(read "perldoc perlvar")
e.g.
$> = $<;
or
($>, $<) = ($<, $>);
$> # is EUID
$< # is UID
$) # is EGID
$( # is GID
(or "use English", see "perldoc English")
...provided you started your script with sufficient privileges (or have it run with suid bit set).
You also can easily fork() and exec() where you swap IDs for the child to restrict possible damage.
Read "perldoc perlipc"
Btw, there is even an Expect.pm at CPAN
http://www.cpan.org/modules/by-module/Expect/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2002 08:22 PM
11-30-2002 08:22 PM
Re: How to switch user by script?
have you tried "sudo" ??
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/sudo-1.6.6/
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 09:10 AM
12-02-2002 09:10 AM
Re: How to switch user by script?
I didn't try to use a sudo because I don't know it. Do you have an example to solve my problem?
Is there a way to solve using a table of "user's equivalence"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2002 06:49 AM
12-05-2002 06:49 AM
Re: How to switch user by script?
For second user, in .rhosts add
hostname username
Then in your script, remsh to your own hostname as the second user.
eg: rlogin `hostname` -l seconduser
We use this to let oracle become applmgr in our oracle financials environment. This is acceptable because oracle is a "higher" privileged user than applmgr.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2002 07:15 AM
12-05-2002 07:15 AM