Computing.Net > Forums > Unix > Change Unix password

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.

Change Unix password

Reply to Message Icon

Name: thanghd
Date: December 15, 2005 at 23:12:28 Pacific
OS: AIX, HP-Unix
CPU/Ram: INTEL3GHZ/2GB
Comment:

I want to use a script for changing automatically a Unix account password. I read a message on this forum the way under :
#!/usr/local/bin/expect --
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd
# Executable 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

But when I run it, it still prompted the line "Retype new Unix password".
How can I run it without the above line?

Pls. recommend me
Thank you so much
Thang



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: December 16, 2005 at 10:34:25 Pacific
Reply:

I don't want to elaborate on the obvious, but did you call it with two arguments:

expectscript unixuser newpass

while logged in as root?

I'm running it on a Solaris 7 box and I'm not having a problem. Perhaps there's a bug with the expect that runs on AIX or HP-UX?

The expect version I'm using is 5.28.1


0

Response Number 2
Name: thanghd
Date: December 18, 2005 at 17:44:37 Pacific
Reply:

Thank for responsing the message, my expect version is 5.43, I tested it on Linux AS 4.
But If still be that above script, but I add two line as under :

#!/usr/local/bin/expect --
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd
# Executable only by root
set password [lindex $argv 1]
spawn /usr/bin/passwd [lindex $argv 0]
# this is two lines that I added
expect "password:"
send "$password\r"
#
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof

and then I rerun it, It was OK

I did not really understand this.

Cheers
Thang


0

Response Number 3
Name: ntrprise
Date: December 21, 2005 at 13:22:32 Pacific
Reply:

i am looking for some thing about the same i am looking for something were i can fire off a script with by a user like "chagepass -p xxxx" and it changes the pass word with out them using the passwd command

thanks


0

Sponsored Link
Ads by Google
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: Change Unix password

Change Unix account for many users www.computing.net/answers/unix/change-unix-account-for-many-users/7307.html

changing unix password through my web page www.computing.net/answers/unix/changing-unix-password-through-my-web-page/1314.html

Unix - How to change my password www.computing.net/answers/unix/unix-how-to-change-my-password/6234.html