Password expire time script "tru64"

From: Binkley Robert - rbinkl (Robert.Binkley@acxiom.com)
Date: Tue May 27 2003 - 11:30:45 EDT


#!/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.



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:20 EDT