Computing.Net > Forums > Unix > Trouble whit command SU

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Trouble whit command SU

Reply to Message Icon

Name: amaury_salazar
Date: September 7, 2005 at 06:54:06 Pacific
OS: UNIX aix 4.3
CPU/Ram: R6000
Comment:

Hi, I would like to know, how can i run the user ( su - Pepe) from a shell script passing the password for parameter or is there another command that do the same? because I run the command but the system gives me the password all time. I would to want what the proccess will be running automatic without what i have to put the password.

Amaury



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: September 7, 2005 at 10:02:10 Pacific
Reply:

This question is asked a lot. The best solution I've seen is to use the expect scripting language. Bundled with expect, is a demo program that does exactly what you're asking for. Here is a modified version of it that you should be able to modify:

#!/usr/local/bin/expect --
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd
# exutable only by root

set password [lindex $argv 1]
spawn /usr/bin/passwd [lindex $argv 0]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof

If your system doesn't have expect, you can probably get it here at the expect home page:

http://expect.nist.gov/


-1
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Trouble whit command SU

On the command who www.computing.net/answers/unix/on-the-command-who/7901.html

help redoing unix script student db www.computing.net/answers/unix/help-redoing-unix-script-student-db/5151.html

SU Command doesn't work www.computing.net/answers/unix/su-command-doesnt-work/3587.html