Simple check login script

Hello,

I just started with shell and i am doin simple script to check if certain user is logged in. Script takes 3 args. name sleep time and quit value

if there is q for quit then date and user name is printed to file, not to screen.

so far i have got this...

login()
{	
	while :
	do
	if [[ `who | grep -c $name` -gt 0 ]]
	then
	echo "\a user $name is logged in"
	echo "User $name has logged in. `date`  >> logs.txt"
        sleep $freq
	else
	echo "User $name is not logged in"
	sleep $freq
	fi
	done
}

loginQ()
{
	while :
	do
	if [[ `who | grep -c $userName` -gt 0 ]]
	then
	echo "User $name has logged in. `date`  >> logs.txt"
        sleep $freq
	else
	sleep $freq
	fi
	done
}
	


if [ $# -le 3 -a $# -ge 1 ] 
then
name=$1
freq=$2
quit=$3

else

echo Invalid number of arguments
fi

if [ -z $frequency ]
then
frequency=60
fi

if [ $quit = q ]
then

loginQ()

else

login()

fi

Could someone help me with that if grep statement,as its not doing the work and is that if statment to check if freq is integer correct ?

In your 1rst test equal or less than 3 and equal or more than 1 leaves, with 1 or 2 or 3 args: so some could be not declared... worse: what happens if only arg3 is give? In your test it would be $1 I dont know what a quitvalue would do as a name...
(you had a missing ] also...)

More I am looking at this script , the more I wonder if it is not homework...

Please send me an PM to reopen this thread, the condition of course is you can assure us this is no school/homework! For homework you have to post in :
Homework & Coursework Questions - The UNIX and Linux Forums
Pay attention to the special rules there...