Ah! What is it? I could see a lot of symbols. I had to ponder about it a bit… Na.. I am joking. How can I ever forget
Unix Shell Scripts? I have a long lasting relationship with it. It is really
interesting to read my thoughts after a long… long… time. Here comes a small
and simple snippet of thoughts….
Unix Shell Script to check every minute whether a user is
logged in or not?
# usage is : scriptname.sh username
if [ $# -lt 1 ]; then
echo improper usage
echo Correct usage
is : $0 username
exit 1
fi
logname=$1
time=0
while true
do
who | grep
`$logname` > /dev/null
if [ $? –eq 0 ] ;
then
echo $logname
has logged in
if [ $time – ne
0 ]; then
echo $logname
is $time minutes late
fi
exit 0
else
time=`expre $time
+ 1`
sleep 60
fi
done
Unix and its look alike or derivatives are really amazing,
may it be linux, solaris, venix, xenix, HP-unix, SCO- Unix. I hope I
recollected my memory accurately. Why don’t you just execute and check… Lot
more on its way… see you again later….
No comments:
Post a Comment