Thursday 21 May 2015

Write a shell script that determine the period for which a specified user is working on system and display appropriate message.VTU MCA LAB8A

echo "enter a user name"
read name
uinfo=`who |grep -w $name | grep 'pts'`

if [ $? -ne 0 ]
then
    echo "user is not loged in yet"
else
    echo "user is there"
min=`who | grep -w $name |tr -s " " " " | cut -c 27-28`
hrs=`who | grep -w $name |tr -s " " " " | cut -c 24-25`
    echo "$uinfo"
   
    mnow=`date +%M`
    if [ $min -le $mnow ]
    then
    echo "some thing"
    min=((($min+60)-$mnow))
    hrs=(($hrs -1))
    echo " $min : $hrs "

fi

1 comment: