Problem
How can I automatically change passwords with OpenServer? Solution
You will need to install the "Expect" programming language available from:
http://www.sco.com/skunkwareor:From your SkunkWare CD provided with your media kit.
Expect is an extension to TCL that allows a script to drive any
application that normally requires human interaction (e.g ftp,
telnet, fsck, rlogin, passwd..). Obvious application areas include
testing, automation and stress-testing or exercising.In addition, such programs can be wrapped with an X GUI using expectk. It also has the distinction of being the first and oldest Tcl extension created.
Once installed there will be an example, "autopasswd" script in:
/usr/local/binHowever, the example provided by Expect version 5.30 doesn't work on OpenServer.
This is because the script doesn't cater to the password options
provided by OpenServer. (i.e. choose password)You can choose whether you pick a password, or have the system create one for you.
1. Pick a password 2. Pronounceable password will be generated for you
Enter choice (default is 1):Change the script to read as follows:
#!/usr/local/bin/expect -f
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd#
# Login name is first arg, password is the second
#
set login [lrange $argv 0 0]
set password [lrange $argv 1 1]#
# Change the login and password
#
set timeout -1
spawn passwd $login
match_max 100000
expect -exact "Enter choice (default is 1):"
send -- "1\r"
expect -exact "New password:"
send -- "$password\r"
expect -exact "Re-enter password:"
send -- "$password\r"
expect eofRun the command as:/usr/local/bin/autopasswd <user> <newpasswd>NOTE: For additional TCL programming, install TCL, also available from
Skunkware. See also
ta109974, "How can user passwords be added or modified non-interactively?"
expect(1)