On Fri, Mar 02, 2001 at 11:29:25AM +1100, John Ferlito wrote:
>       I used to have a little program once that would let me set
> passwords via a script but I can't remember wat it was called. ie
> something the lets me do.
> 
> setpasswd -u user -e encryptedpw
> 
>       Yes I'm feeling to lazy to write a perl script :) Anyone
> remember what it was called.

I ended up writing the perl script :)

#!/usr/bin/perl -w

open(PW, "/tmp/pw");
while ($line = <PW>) {
  ($user, $pw, undef) = split(/:/, $line, 3);
  $password{$user} = $pw;
}
close(PW);
# user:wO.Ebiy8PYdgI:10987:0:99999:7:::
open (SH, "/etc/shadow");
open (SH2, ">/tmp/shadow");
while($line = <SH>) {
  chomp($line);
  ($a, $b, $c, $d, $e, $f, $g, $h, $i) = split(/:/, $line);
  if(defined ($password{$a}) ) {
    $b = $password{$a};
  }
  print SH2 "$a:$b:$c:$d:$e:$f:$g:$h:$i\n";
}

-- 
John Ferlito
Senior Engineer - Bulletproof Networks
ph: +61 (0) 410 519 382
http://www.bulletproof.net.au/

-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug

Reply via email to