[ale] scripting passwd change

Joe Knapka jknapka at earthlink.net
Tue Aug 22 15:30:08 EDT 2000


You probably need to use "expect". passwd detects whether its
standard input is connected to a tty; if not, you lose. Luckily,
password-changing is one of the canonical expect example:

#!/usr/bin/expect
spawn passwd
expect "ssword:"
send [lindex $argv 0]
expect "ssword:"
send [lindex $argv 1]
expect "ssword:"
send [lindex $argv 1]
expect eof

Save as cpasswd.tcl, chmod u+x cpasswd.tcl, and invoke with:

cpasswd.exp <current password> <new password>

-- Joe

Ben Phillips wrote:
> 
> Say I want to change my own password from a script.  Is there any way to
> make /usr/bin/passwd cooperate with this?  I can make a file like:
> 
> oldone
> newone
> newone
> 
> ...and if I run 'passwd < myfile' it somehow knows I'm doing this and
> rebels ("error changing password").  How do I bend it to my will?
> 
>                       __   _                 "I hate to advocate drugs,
> Ben Phillips         /  '_' )         ,,,     alcohol, violence or
> pynk at post.com        |  | ()|||||||||[:::)    insanity, but they've
>                      \__.-._)         '''     always worked for me."
>                                                  -- Hunter S. Thompson
> 
> 
> --
> To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.

-- 
*** Joseph Knapka ***
In any formula, constants (especially those obtained from handbooks)
are to be treated as variables.
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list