#! /bin/sh # # Script to report (on screen, if no redirection) on expired passwords. tmpfile="/tmp/checkexpd.$$" if [ `whoami` != "root" ] then echo "Only root can run this script" exit 1 fi month=`date +%b` day=`date +%e` year=`date +%Y` now="$month $day, $year" cat /etc/passwd | cut -d ':' -f1 > "$tmpfile" sync sleep 1 while read id do line=`chage -l $id | grep "Password Expires:"` expdate=`echo $line | cut -d ' ' -f3-` result=`datecmp $expdate $now` if [ $result -eq -1 ] then echo -e "$id \t$expdate" fi done < "$tmpfile" sync sleep 1 rm $tmpfile exit 0