> Thanks very much Richard, I had not used "awk" before so I had to go read up
> on it a little before I continued.
> OK, script 2 is supposed to show a list of users who have not logged on, or
> who haven't logged on for 3 months or more.
> Using the header:
> INACTIVE USERS (Students) as at <todays date>
> User Name Full Name Last Logged on
> here is what I have written, but cannot seem to get any users from:
At what point does it not work?
Quote:> clear
> date '+INACTIVE USERS (Students) as at %d %b %y'
> echo "User Name Full Name Last Logged on"
> finger /home/students/* |tail +3 |head -1 |\
Did you get the output you want from this when you tried it by itself?
How many lines do you think "head -1" will give you?
Will that line give you the information you need?
Quote:> while read line ; do
> userid=${homedir##*/}
Where did you assign a value to $homedir?
Quote:> currentmonth='date "+ %m"'
Move this outside the loop. You only need to do it once.
Quote:> lastonmonthnumber=0
> if [ $1 == "Never" ] ; then
> lastonmonth=Never
> else
> lastonmonth=$3
See my next note.
Quote:> fi
> if [ $4 == "Jan" ] ; then
Is the month in the 3rd or the 4th field?
Quote:> lastonmonthnumber=4
Why is "Jan" number 4?
Quote:> elif [ $4 == "Feb" ] ; then
> lastonmonthnumber=5
> elif [ $4 == "Mar" ] ; then
> lastonmonthnumber=6
> elif [ $4 == "Apr" ] ; then
> lastonmonthnumber=7
> elif [ $4 == "May" ] ; then
> lastonmonthnumber=8
> elif [ $4 == "Jun" ] ; then
> lastonmonthnumber=9
> elif [ $4 == "Jul" ] ; then
> lastonmonthnumber=10
> elif [ $4 == "Aug" ] ; then
> lastonmonthnumber=11
> elif [ $4 == "Sep" ] ; then
> lastonmonthnumber=12
> fi
> if [ $lastonmonthnumber -le $currentmonth ] ; then
> echo "$userid:$lastonmonth:\
Where did you assign a value to $userid?
Quote:> `grep "^$userid" /etc/passwd | cut -d":" -f5`"
> awk -F: '{printf "%-12s %-24s %-25s\n",$1,$3,$2}'
> fi
> done
Try soemthing like this:
currentmonth=`date +%m`
for dir in /home/students/*
do
finger `basename $dir` | {
read _ userid _ username ### underscore '_' is a throw-away
read _
read ever _ day lastonmonth date time
if [ "$lastonmonth" != "Never" }
then
### do your calculations here
fi
}
done
--
Chris F.A. Johnson http://cfaj.freeshell.org
===================================================================
My code (if any) in this post is copyright 2001, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License