Script to AutoKill PIDs of LOGED in Active User

:confused: Hi
i am trying to make a script through which i can get the total number of User and their PID after that kill all Users except the one by which i am currently logged in. (i m using SCO UNIX 5.06)

# id of current usre < total number of current user
USR=`who -u |wc -l`

# id of current user
IAM=`who -u -m |cut -b 43-49 |cut -d " " -f1,2,3,4,5`

# name of current user
IM=`who am i | cut -d" " -f1`

# Process ids of all users
PUID=who -u |grep $IM$ |cut -b 43-49 |cut -d " " -f1,2,3,4,5

# Icremental variable

KILPID=0

# This loop will run until the KLPID VAR not equal to the number of user.
while test ${KILPID} -le $USR
do
if [ $IAM != $PUID]
then
kill -9 $PUID
fi
KILPID=`expr ${KILPID} + 1`
done

Hi.
I would do the following instead:

MYTTY=$(tty | sed 's/\/dev\///')
kill $(who -u | grep -v "$MYTTY" | awk '{print $7}')

This will kill other users' sessions except your one. Though, this may not be what you want...

Besides,

Regards.

(I Forgot to mention I'm using AIX 5.2)

Seeing as only root can kill other people's processes you are really saying kill everyone else except root, why not just take the machine down to single user level?