W.A.S.S to check whether user has logged in or not.
Program
# W.A.S.S to check whether user has logged in or not.
echo "Enter the user name:"
read usr
flag=0
for w in ` who | tr -s " " | cut -d " " -f1`
do
if test $usr = $w
then
echo "User is logged in.."
flag=1
fi
done
if test $flag = 0
then
echo "User is Not logged in.."
fi
Output:
Enter the user name:
root
User is logged in..
Enter the user name:
narenda
User is Not logged in