#!/bin/perl -w
use strict;
my $secs_in_day = 60 * 60 * 24;
my $now = int ((time)/($secs_in_day));
my $host = `uname -n`;
chomp $host;
foreach ( `who` )
{
my ($uhost, $user)
/^(\w+).*\((.*)\)/ and $user = $1, $uhost = $2 or next;
my $chtime = `lssec -f /etc/security/passwd -s $user -a lastupdate`;
$chtime =~ s/^.*?=(\d+)/$1/;
$chtime or (print STDERR "$user has nver been updated\n"), next;
$chtime = int ($chtime/$secs_in_day);
$chtime = $now - $chtime;
$chtime < 42 and next;
$chtime > 56 and (system "echo Your password on $host has expired - Contact Unix support to reset | mail -s \"Password on $host\" $user\@mailserver"), next;
$chtime = 56 - $chtime;
system "echo Your password on $host will expire in $chtime days - please log i
n and reset it | mail -s \"Password on $host\" $user\@mailserver";
}