Technical article 114483

How can I automatically change passwords with OpenServer?

OpenServer 5.0.5OpenServer 5.0.6OpenServer 5.0.7

Written · Last revised

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/skunkware
or:

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/bin

However, 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 eof
Run 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)

From the Xinuos technical article database, record 114483. Reproduced with permission. The original is at www.sco.com/ta/114483, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.