J. Goodleaf writes: 

> Well it works. The changes I made seem trivial to me, but it does work 
> now. I can both authenticate and change passwords (using the authpam 
> scheme). The file now looks like:
> (excepting the comments of course)  
> 
> set timeout 30  
> 
> expect {
>       -re "(.*)\n(.*)\n" { set oldpass "$expect_out(1,string)" ; set newpass 
> "$expect_out(2,string)" }
>       eof { exit 1 }
>       timeout { exit 1 }
> }  
> 
> spawn "/usr/bin/passwd"  
> 
> expect {
>       -re "Old" { sleep 2; send "$oldpass\n" }
>       eof { exit 1 }
>       timeout { exit 1 }
> }  
> 
> expect {
>       -re "nvalid" { exit 1 }
>       -re "New" { sleep 2; send "$newpass\n" }
>       eof { exit 1 }
>       timeout { exit 1 }
> }  
> 
> expect {
>       -re "nvalid" { exit 1 }
>       -re "NVALID" { exit 1 }
>       -re "bad pass" { exit 1 }
>       -re "BAD PASS" { exit 1 }
>       -re "dictionary" { exit 1 }
>       -re "common" { exit 1 }
>       -re "short" { exit 1 }
>       -re "Retype" { sleep 2; send "$newpass\n" }
>       eof { exit 1 }
>       timeout { exit 1 }
> }  
> 
> expect {
>       -re "nvalid" { exit 1 }
>       -re "nchange" { exit 1 }
>       -re "same" { exit 1 }
>       -re "passwd:" { exit 0 }
>       eof { exit 0 }
>       timeout { exit 1 }
> }  
> 
> exit 1  
> 
> All I did was tweak a couple of things, most notably in the last expect 
> clause, where I added the "passwd:" line. Hope someone finds it useful. If 
> someone thinks it's grotesquely incorrect, just let me know. 

Well, it doesn't look right to me.  Why don't you show an sample passwd run 
to see what the actual prompts look like.  There's probably a better way to 
script it. 

-- 
Sam 

Reply via email to