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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Trouble whit command SU

Reply to Message Icon

Original Message
Name: amaury_salazar
Date: September 7, 2005 at 06:54:06 Pacific
Subject: Trouble whit command SU
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


Report Offensive Message For Removal


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/


Report Offensive Follow Up For Removal







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



Results for: Trouble whit command SU

Unix mail with attachment and a body
    Summary: Use the following mail command: (uuencode filetobeattachment attachmentname.extension; uuencode filetobeattachment attachmentname.extension; echo "text") | mail -s "Subject" EmailAddress The above com...
www.computing.net/answers/unix/unix-mail-with-attachment-and-a-body/2421.html

Unix Command Script
    Summary: #!/bin/ksh # set -x localmail() { echo "What is the mail recipient?" read mailto echo "What full path to the file would you like to attach?" read fullpath attachment=`echo $fullpath | awk -F "/" ...
www.computing.net/answers/unix/unix-command-script/4244.html

Send mail on UNIX
    Summary: Hi, I have a question. how do we send a mail on one line command?? like it should include the.... recipent, subject, body, I found some sources online but, it doesnt send it right away.. I tried pi...
www.computing.net/answers/unix/send-mail-on-unix/4064.html








Which MP3 player do you have?

iPod/iPhone
Zune
Something Else
None


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History






Data Recovery Software