CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: Throw Down The Gauntlet:
system admin

 



conor
stranger

Jul 20, 2001, 9:10 AM

Post #1 of 2 (15618 views)
system admin Can't Post

could anyone please help me find a program that would aid a system administrator .
it would read a password file (with the fields being, day month year and time in hrs mins and secs when a user has last logged onto the system).
and check to see if the user has logged onto the system in the last 30 days.
cheers.




Kanji
User / Moderator

Jul 20, 2001, 5:52 PM

Post #2 of 2 (15610 views)
Re: system admin [In reply to] Can't Post


Code
#!/usr/bin/perl -wl 

use strict;
use Time::Local;

my $PASSWORD = "/path/to/password.file";
my $DAYS = 60 * 60 * 24 * 30; # in seconds

open PASSWORD, $PASSWORD or die "Cannot open $PASSWORD: $!\n";
while (<PASSWORD>) {

# user:password:day:month:year:hours:minutes:seconds

my($u,$p,$D,$M,$Y,$h,$m,$s) = split /:/;

$M -= 1;
$Y -= 1900;

print $u if (time - timelocal($s,$m,$h,$D,$M,$Y)) > $DAYS;
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives