Guest_imported
New member
- Jan 1, 1970
- 0
I wrote this script to logoff idle users but having a bit of a problem. Can someone look at this please.
#!/bin/sh
who -u | grep -v 'dtlocal' | nawk '{printf("%10s %10s %10s %\n",$1,$6,$7)}' > my
cat my | nawk '{printf("%10s %10s %10s %\n",$1,$2,$3)}' | grep '[2-9][5-9]*:[0-9][0-9]' > myfile
for id in `cat myfile | nawk '{print $1, $2, $3}'`
do
echo "you have been idle for 25 minutes" | write $id > lastime
done
for i in `cat lastime | nawk '{print $1, $2, $3}'`
do
echo "You are now being logged off" | write $i
kill -9 $i
done
#!/bin/sh
who -u | grep -v 'dtlocal' | nawk '{printf("%10s %10s %10s %\n",$1,$6,$7)}' > my
cat my | nawk '{printf("%10s %10s %10s %\n",$1,$2,$3)}' | grep '[2-9][5-9]*:[0-9][0-9]' > myfile
for id in `cat myfile | nawk '{print $1, $2, $3}'`
do
echo "you have been idle for 25 minutes" | write $id > lastime
done
for i in `cat lastime | nawk '{print $1, $2, $3}'`
do
echo "You are now being logged off" | write $i
kill -9 $i
done