Tuesday 3 April 2018

shell script to count the login users and welcome them

#Script to count login users and welcome them
dt=`date +%H`
echo "No. of users currently logged in : `who|cut -d " " -f 1|uniq| wc -l`"
if [ $dt -lt 12 ] ; then
    echo "We welcome you all. Good Morning!"
elif [ $dt -lt 16 ] ; then
    echo "We welcome you all. Good Afternoon!"
else
    echo "We welcome you all. Good Evening!"
fi




OUTPUT
csc@csc-SVE1513CYNB ~ $ sh usrCnt.sh
No. of users currently logged in : 1
We welcome you all. Good Evening!

No comments:

Post a Comment