From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,f0e73e6c57c7eb58 X-Google-Attributes: gidfee84,public From: rdw@hooked.net (Richard Warkentin) Subject: Re: Setting password from a shell script possible? Date: 1995/12/24 Message-ID: <4bkvaf$rbp@its.hooked.net>#1/1 X-Deja-AN: 122741304 references: <1995Dec19.160036@malad2.mala.bc.ca> <95355.204430JONQC@CUNYVM.CUNY.EDU> organization: Hooked Online Services newsgroups: comp.unix.osf.osf1 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