#!/bin/bash
IFUSER() {
read -p "Please input a user name" USERNAME
if id $USERNAME &> /dev/null; then
return 0
else
echo "The $USERNAME not exist."
exit 6
fi
}
let LASTDATE=`grep "$USERNAME:" /etc/shadow |cut -d: -f3`
#用户上次修改密码的时间
#现在时间
#最长使用期限
if [ $WARNDATE -gt 10 ];then
echo "$WARNDATE"
else
echo "Please change your password in $WARNDATE"
fi
}
LASTLOGIN=`finger $1 | grep "Last login" | sed "s/.*Last login//g"`
echo "$1 last login time is: $LASTLOGIN"
}
WARNUSER $USERNAME
LASTLOG $USERNAME