in reply to Unix password change
If you want to interface yourself to the passwd program you should use some Expect module. Take a look on CPAN, I can't suggest any Expect module because search.cpan.org is currently unreachable for me.
Otherwise, you can calculate a "crypt string" by means of the crypt function and then substitute the it to the password string in the /etc/passwd file.
Maybe this quick-and-dirty script could help you getting started; I use it to calculate a crypt string, given the password:
#!/usr/bin/perl print "Password? > " ; $_ = <STDIN> ; chomp ; srand ; print crypt($_, join('',('.', '/', 0..9,'A'..'Z', 'a'..'z')[rand 64, rand +64])), "\n" ;
Ciao!
--bronto
Update: just a note: the srand was needed to make the script run correctly on some old IBM machines that ran Perl 4.
The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unix password change
by Anonymous Monk on Mar 28, 2003 at 14:58 UTC |