SUMMARY - Convert lastchg field in shadow file to date

From: Alan Bradley - CPX WC <AlanB_at_ComparexAfrica.co.za>
Date: Fri Nov 15 2002 - 05:06:23 EST
Hi All,

Thanks very much to:

John Leadeham
Bertrand Hutin
Jonas Bleberg

The answers consisted of me being sent 2 perl scripts (The one from Jonas
Bleberg, which I ended up using, is below) and also a suggestion to use Gnu
date, which is part of the shutils package available from
www.sunfreeware.com  -  Gnu date does date arithmetic:

$ date -s "1 January 1970 + 12000 days"
Sat Nov  9 00:00:00  2002

Perl script:
------------

#!/usr/local/bin/perl

# Output date format is YYYY-MM-DD

open( S, "/etc/shadow" );
while( <S> )
  {
  ($user,$lastchg) = (split /:/)[0,2];
  @t = localtime( $lastchg*86400 );
  printf "User %-8s last changed password %0.4d-%0.2d-%0.2d (%5d)\n",
         $user, $t[5]+1900, $t[4]+1, $t[3], $lastchg;
  }
close( S );

exit 0;


Regards,
Alan.


NOTICE: The contents of this message and any attachments are personal to the
sender and, whilst having been sent using the Comparex Africa (Pty) Ltd
e-mail system, are not, and should not be construed as having been sent on
behalf of Comparex Africa (Pty) Ltd.
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Fri Nov 15 05:11:19 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:58 EST