[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Expect with passwd



Hilaire,

On Thu, 8 Apr 1999, Hilaire Fernandes wrote:
> I call it setpasswd and then I can do "setpasswd teo 21refs" to set
> 21refs as the password of user teo.

Not good.  Passwords are recorded in ~/.bash_history -- and in the clear.

Since you're using expect, it might as well be made interactive:

------
 #!/usr/bin/expect -f

    stty -echo
    send_user "Password? "
    expect_user -re "(.*)\n"
    set pass $expect_out(1,string)
    puts \n
    stty echo

 spawn passwd [lindex $argv 0]
 expect {
        password: {send "$pass\r" ; exp_continue}
        eof exit
 }
------

---
Rhandeev Singh                    http://www.comp.nus.edu.sg/~rhandeev
Mobile Computing Group		  http://cram.comp.nus.edu.sg:8080/cram
Centre for Internet Research	  http://www.cir.nus.edu.sg
National University of Singapore  http://www.nus.edu.sg