From: rdw@hooked.net (Richard Warkentin)
Subject: Re: Setting password from a shell script possible?
Date: 1995/12/24 [thread overview]
Message-ID: <4bkvaf$rbp@its.hooked.net> (raw)
In-Reply-To: 95355.204430JONQC@CUNYVM.CUNY.EDU
<JONQC@CUNYVM.CUNY.EDU> wrote:
>> I'm trying to write a procedure to do a "bulk create" of accounts
>> (for setting up accounts for CSci classes). I've figured out how to
>> get the adduser portion to take its input from a script, but it appears
>> that regardless of what I do the passwd program always reads from the
>> terminal.
>
>We had the same problem. At the beginning of every semester, we need to
>put up bulk accounts for new students. The answer to your problems is
>the 'expect' program that is mentioned in the OSF FAQ; 'expect' can
>"talk" to 'passwd'.
>
>The quickest way to go is: Copy the 'expect' program from the
>OSF/1 Freeware disc, modify the 'adduser' script to ask for the
>password (which you've probably done already), and then add a line to
>'adduser' to let 'expect' do the rest:
>
> setpass ${USER} ${PASSWD}
>
>where the 'setpass' script contains the following:
>
>#!/usr/local/bin/expect
>set password [lindex $argv 1]
>spawn passwd [lindex $argv 0]
>expect {*quit):}
>send p\r
>expect {*password:}
>send $password\r
>expect {*password:}
>send $password\r
>expect eof
>
>NOTE: The FAQ file says that lines 2 & 3 should read "index" instead of
>"lindex". However, the current copy of 'expect' that we downloaded from
>ftp.cme.nist.gov (you also need to download 'tcl' if you're going to
>make 'expect' from scratch) requires "lindex". I don't know whether the
>version on the Freeware disc uses "index" or "lindex" but that's easy to
>find out.
>
>FYI: We usually set the initial password to the student's social
>security number. If you're running C2 security (you probably should
>be), you can force them to change their initial password right away by
>pre-expiring it. To do this, add the following 2 lines to 'adduser'-
>
>#Delete 'u_succhg' entry in auth file to pre-expire the password
>ed -s "${AUTHDIR}/${USER}" < /usr/sbin/adduser.ed_commands
>
>Where the file 'adduser.ed_commands' contains the following 3 lines-
>
>1,$s/u_succhg#[0-9]*://
>w
>q
>
>Admittedly, I'm still kind of a novice Unix user so maybe someone on
>the Net can figure out how to accomplish the pre-expiration all on one
>line that doesn't require a second input file but for now, this works.
>
>Hope this helps.
>
>Jon Leong
>Systems Manager
>Queens College
>City University of New York
next prev parent reply other threads:[~1995-12-24 5:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-12-19 5:00 Setting password from a shell script possible? Malcolm Dunnett
1995-12-21 5:00 ` JONQC
1995-12-21 5:00 ` Malcolm Dunnett
1995-12-24 5:00 ` Richard Warkentin [this message]
1995-12-27 5:00 ` PAUL D. CHAPIN
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox