Write a shell script to read user name and find whether the user is currently working in the system or not

Write a shell script to read user name and find whether the user is currently working in the system or not

Code:

clear
echo ---------------------------------------------
echo '\tUser currently working or not'
echo ---------------------------------------------
echo Enter the user name
read name
if who | grep $name
then
echo User is working currently.
else
echo User is not working currently.
fi

Output:

---------------------------------------------
User currently working or not
---------------------------------------------
Enter the user name
elcot
elcot    tty7         2013-12-21 11:02 (:0)
elcot    pts/0        2013-12-21 11:06 (:0.0)
User is working currently

No comments

Powered by Blogger.