home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!charnel!rat!usc!zaphod.mps.ohio-state.edu!darwin.sura.net!gatech!destroyer!ncar!noao!bordeaux.kpno.noao.edu!jdavis
- From: jdavis@bordeaux.kpno.noao.edu (Jim Davis)
- Newsgroups: comp.unix.admin
- Subject: Re: passwd
- Message-ID: <1993Jan8.210155.6454@noao.edu>
- Date: 8 Jan 93 21:01:55 GMT
- References: <1ikbatINNgl8@matt.ksu.ksu.edu>
- Sender: news@noao.edu
- Organization: Thomas Tupper Jr. High
- Lines: 25
- Nntp-Posting-Host: bordeaux.kpno.noao.edu
-
- In article <1ikbatINNgl8@matt.ksu.ksu.edu> holland@matt.ksu.ksu.edu (Rich Holland) writes:
- >Does anyone know how to make passwd behave non-interactively? We've tried
- >(echo newpass ; echo newpass ) | passwd, but it wants the passwords to be
- >typed in from the keyboard. I need to do this in a script, to set up new
- >account passwords...
-
- Try using 'expect', a tool written by Don Libes at NIST. Very useful in
- general, and can solve this problem neatly. Here's an example expect script
- from the source distribution that could do what you want:
-
- #!../expect -f
- # wrapper to make passwd(1) be non-interactive
- # username is passed as 1st arg, passwd as 2nd
- set password [lindex $argv 2]
- spawn passwd [lindex $argv 1]
- expect {*password:}
- send "$password\r"
- expect {*password:}
- send "$password\r"
- expect eof
-
- You can pick up expect by anonymous ftp from durer.cme.nist.gov:/pub/expect
- --
- Jim Davis | "No way! I mean, it did? I mean of course it did!
- jdavis@noao.edu | I mean, NO WAY!" -- Clarissa Darling
-