Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automating changing the user on Solaris 2.6 1

Status
Not open for further replies.

bone

Technical User
Sep 23, 2001
3
0
0
GB
Hi,

I am having a problem running a script as a different user on a Solaris box. Basically i want to allow 'User2' to run 'ScriptX'. However, the script can only be run by 'User1' (for many reasons). So I would like to write an automated script to be run by 'User2' which logins into the system as 'User1' and then runs 'ScriptX'.

However, I am having a problems finding a way of passing both login and password to a Unix login command. For example, "su - User1" allows me to login as 'User1', though there is no way of passing the password that I can see. Can anyone help? Thanks!

Brandon
 
Could you place the executable on a shared file system? That way you could automount (or mount it in /etc/vfstab) it and spare yourself the agony of rsh/rlogin.

Also, check to see if you and the other user are in the same user group, and give executable permissions to the group.

If the script produces output files, make sure the group has write permissions to that directory.

Hope this helps!
 
You only must be sure both [tt]user1[/tt] and [tt]user2[/tt] are in the same group then [tt]chgrp SameGroup ScriptFile[/tt], then make sure the group can execute the script with [tt]chmod g+rx ScriptFile[/tt]. Then, try to run the script...

I hope it works...
 
Thanks very much for the feedback. However, the script must be run in its current location as another user for reasons other than user groups and user privileges.

What I really need is a way to script changing the user...with the login and password included in the script. Any further feedback is greatly appreciated!
 
I'd suggest looking at 'expect' and 'perl'. Both of these languages together can do what you need them to do.
Jon Zimmer
jon.zimmer@pf.net
The software required `Windows 95 or better', so I installed Linux.

 
It is not necessary to log in as user1.
User1 should set the s-Bit to the script.
In that case user2 could run the script with the permissions of user1.

hnd
hasso55@yahoo.com

 
you could <shudder> do an 'su - <person> -c &quot;command&quot; ' and have an '.rhosts' file with the user in it ...

that'd work for you ... i guess
 
ooh, ooh i've thought of another ...

create a new user (same uid/gid) with the shell set to the command you want to run.

empty the password ...

su - <newuser>

that should change to that user, and run that command :)
 
Or try to use the [tt]sudo[/tt] package. It was designed precisely to solve the same problem you have. yo can specify what users can change to some other user without password, but specifying exactly what commands can these users run.
 
Try to use the [tt]sudo[/tt] package, it was designed precisely to solve the problems like yours.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top