home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / admin / 6990 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  1.5 KB

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