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#
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