Password expiry report

Hi All,
I want to write a script that will send the alert when linux server password expiry for user 'x' is less than 12 days.
I have written the below script but this is not working for expiry date 04 july

script;-

P_EXPIRY_DATE=`chage -l msdp| grep 'Password expires'   | awk ' { print $5 }' | cut -c1,2`
T_DATE=`date '+%e'`
P_EXPIRY_DAYS_LEFT=`expr $P_EXPIRY_DATE - $T_DATE`
if 
then
condition
else 
condition
fi 

Any help will be really appreciated !!!!!!!

try this :wink:
http://www.unix.com/red-hat/176969-script-email-admin-users-expired-passwords.html

How about this:

EXP=$(chage -l msdp | awk -F: '/Password expires/{ print $2}')
if [[ $EXP =  *never ]]
then
    EXP_DAYS=9999
else
    NOW_SEC=$(date +%s)
    EXP_SEC=$(date -d "$EXP" +%s)
    EXP_DAYS=$((( EXP_SEC - NOW_SEC ) / 3600 / 24))
fi
if [ $EXP_DAYS -lt 12 ]
then
   echo "Will expire in $EXP_DAYS days"
else
   echo "Still a while to go yet"
fi