Write a Shell Program To Test Whether a Particular User Logged In Gain Infiniti

Write a Shell Program To Test Whether a Particular User Logged In


username=$1
who | grep -q $username
if [ $? == 0 ]
then
    echo "$username is Logged in"
else
    echo "$username is !Logged in"
fi



OUTPUT:-

#!/bin/bash
#root@slack-linunx:~/scripts# ./loginUserCheck.sh root
#root is Logged in
#root@slack-linunx:~/scripts#

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 

Design By Manish and Ranjan