Showing posts with label Detecting user when logged on. Show all posts
Showing posts with label Detecting user when logged on. Show all posts

Friday, April 3, 2015

Detecting user when logged on

Program (logdetect.sh)
#!/bin/bash
#Detect the user at logon
while true
do
if who|grep $1>/dev/null
then
echo $1 is logged in
exit
fi
done

Output
[vijai@localhost command]$ sh logdetect.sh cse1
cse1 is logged in