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

Using Expect with passwd



I have a problem with a script, can someone help ?


I've written a small script for expect to setup user password without
interaction :

------
#!/usr/bin/expect -f
spawn passwd [lindex $argv 0]
set pass [lindex $argv 1]
expect {
        password: {send "$pass\r" ; exp_continue}
        eof exit
}

------

I call it setpasswd and then I can do "setpasswd teo 21refs" to set
21refs as the password of user teo.
But strangely this script work randomly, some time it works fine but
some time it doesn't, it may do the first pass then hang for few seconds
then go back to the shell.


Any idea

-- 
Hilaire Fernandes 
Dr Geo project http://www.drgeo.seul.org