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

No comments:

Post a Comment