Hi;
im a newbee for linux. i have a home work which i wrote as bellow. anybody can help me to correct what is wrong. im appreciated.
the question is:
write a script to check users' id and ensure they have:
1. specific min days to change password (7)
2. specific max days to change password (30)
3. specific warning days (5)
4. ensure the "last changed" setting for each user occured in the past and report any that do not match this (include the date set in the shadow file in the report)
if -o option is passed as a command line, interactively prompt the user do:
1. disabling accounts
2. force change a users password
3. force a user to change password at next login.
#!/bin/sh
if [ $# -ne 1 ]; then
cat /etc/passwd | while read line
do
if [ echo `awk -F: '{print $3}' $line` > 500 ]; then
username = echo `awk -F: '{print $1}' $line`
temp = echo `passwd -S $username`
if [ echo `awk -F: '{print $3}' temp` ne 7 ]; then
passwd -n7 $username
fi
if [ echo `awk -F: '{print $4}' temp` ne 30 ]; then
passwd -x30 $username
fi
if [ echo `awk -F: '{print $5}' temp` ne 5 ]; then
passwd -w5 $username
fi
if [ grep -v '\/[0-9][0-9]\/[0-9][0-9]\/2003' `echo `awk $2 temp`` ]; then
echo $line
fi
fi
done
else
cat /etc/passwd | while read line
do
if [ echo `awk -F: '{print $3}' $line` >= 500 ]; then
username = echo `awk -F: '{print $1}' $line`
temp = `passwd -S $username`
if [ echo `awk -F: '{print $3}' temp` ne 7 ]; then
passwd -n7 $username
fi
if [ echo `awk -F: '{print $4}' temp` ne 30 ]; then
passwd -x30 $username
fi
if [ echo `awk -F: '{print $5}' temp` ne 5 ]; then
passwd -w5 $username
fi
if [ grep -v '^\/[0-9][0-9]\/[0-9][0-9]\/2003' `echo `awk $2 temp`` ]; then
echo $line
fi
if [ $1 = -o ]; then
echo 'Enter the command as bellow:'
echo 'l -- for disable the password'
echo 'p -- force change a users password'
echo 'f -- force change his/her passwd at next login'
if [ $1 = l ]; then
passwd -l $username
fi
if [ $1 = p ]; then
passwd -x1 -n1 $username
fi
if [ $1 = f ]
passwd -f $username
fi
fi
fi
done
fi
exit 0