tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* Password expire time script "tru64"
@ 2003-05-27 15:30 Binkley Robert - rbinkl
  0 siblings, 0 replies; only message in thread
From: Binkley Robert - rbinkl @ 2003-05-27 15:30 UTC (permalink / raw)



#!/usr/bin/perl
  $host=`hostname`; chomp($host); 
      $cnt=0; 
      $from="root\@$host.com"; 
      $sendmailpath="/usr/sbin/sendmail"; 
      $pwfile="/etc/passwd"; 
       open (PASS,"<$pwfile") or die "File doesn't Exist"; 
       while (<PASS>) 
             { 
              @userline = split (":",$_); 
              chomp(@userline); 
              $user = $userline[0]; chomp($user);   
      open(GETAUTH,"/usr/tcb/bin/edauth -g $user|") || die "Error $!"; 
      my $myString=""; 
      while(<GETAUTH>) 
           { 
            $myString .= $_; 
           } 
        close(GETAUTH); 
       ($_ = $myString) =~ tr/:\\\n\t/:/sd; 
       if(/u_succhg#\d*/) 
          { 
          $_ =~ m/u_succhg#(\d*)/; 
          $last_change=$1; 
          chomp($last_change); 
            $def_exp = 7776000; # 90 Days 
            $myexpiry = $last_change+$def_exp; 
            $info_date = $myexpiry-172800; 
            $exp_date=scalar localtime($myexpiry); 
            $today=time; $reportdate=scalar localtime($today); 
            $dtexp=$myexpiry-$today; #In Seconds 
            print "$user => dtexp => $dtexp , myexpiry => $myexpiry\n"; 
            if ($myexpiry != 7776000  and $dtexp < 172800) 
               { 
             $cnt++; 
             if ($dtexp < 0) 
               { 
                $myverb = "Expires On"; 
               } 
             else 
               { 
               $myverb = "Will Expire On "; 
               } 
             $exp_list .= "==>> $user\'s Password $myverb on $exp_date\n"; 
               } 
           } 
} 
         if ($cnt > 0) 
            { 
            # $to="root\@domain.com,root\@domain.com"; # Need to edit this
line
             $subject=uc($host)." Password Expiry Report of $reportdate"; 
             open (SENDMAIL, "| $sendmailpath -t"); 
             print SENDMAIL "Subject: $subject\n"; 
             print SENDMAIL "From: $from\n"; 
             print SENDMAIL "To: $to\n\n"; 
             print SENDMAIL "Password Expiration List, Check & Take
action\n\n"; 
             print SENDMAIL "$exp_list\n\n"; 
             print SENDMAIL "Bye!\n\n"; 
             print SENDMAIL "root"; 
             close (SENDMAIL); 
             } 

#####################################output#################################
###

root => dtexp => 7078199 , myexpiry => 1061127491
wnn => dtexp => 7078193 , myexpiry => 1061127486
pop => dtexp => 7078193 , myexpiry => 1061127486
imap => dtexp => 7078193 , myexpiry => 1061127486
opensys => dtexp => 7078193 , myexpiry => 1061127486
oracle => dtexp => 7078193 , myexpiry => 1061127486
iass => dtexp => 7078193 , myexpiry => 1061127486
httpd => dtexp => 7078193 , myexpiry => 1061127486
jlemle => dtexp => 7078193 , myexpiry => 1061127486
cvs => dtexp => 7078192 , myexpiry => 1061127486





**********************************************************************
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, 
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-05-27 15:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-27 15:30 Password expire time script "tru64" Binkley Robert - rbinkl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox