#!/usr/bin/perl -s use strict; our($r,$recover); my $mexroot = $r || "/home/natura/mex/public/users"; $mexroot =~ s/\/$//; my %users; my ($u,$p) = @ARGV; die("user?\n") if( not $u || $recover); _readusers(); $p //= $u ; $users{$u}=$p if $u; _recover() if $recover; _writeusers(); sub _readusers{ $mexroot //= "/home/natura/mex/public/users"; open(A,"<","$mexroot/passwd") or warn("cant find $mexroot/passwd\n"); while(){ next if /^#/; if(/^(\S+?):([^:\s]+)/){ $users{$1}=$2 } } close A; } sub _writeusers{ open(A,">","$mexroot/passwd") or warn("cant write $mexroot/passwd\n"); for(keys %users){ print A "$_:$users{$_}\n"; } close A; sleep 1; chown("apache","apache","$mexroot/passwd"); # chown("www-data","www-data","$mexroot/passwd"); } sub _recover{ while(){ if(/(\w+)/){ $users{$1}//=$1;} } } __END__ carla gjm guida ines ireneb isabel jj jmp lau.horta nrc ricardo rmp rosario smirnov susana teresa suzana claudia paula jes