Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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 rootset password [lindex $argv 1]
spawn /usr/bin/passwd [lindex $argv 0]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eofBut 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

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

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 eofand then I rerun it, It was OK
I did not really understand this.
Cheers
Thang

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

![]() |
![]() |
![]() |

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