I have been having an issue with the new motorola rf scan guns opening up too many sessions at once. It seems they will open a new connection for no reason, leaving the old one in the background and the user has no idea it is happening. To combat this, I have added the following code to the logon profile script that is supposed to see if the user's IP address is already logged on and if it is, it will kill the old session and let the new one on:
IP=$(who am i| awk '{print$6}')
IPCNT=$(who -u | grep $IP |wc -l)
if [$IPCNT -ge 1 ]
then
who -u | grep $IP |sed -e 's/://g' | awk '{print$6,$7,$8}' > idle
cat idle | sort -k6 | awk '{print$2}' > idlegood
pts=$(who am i|awk '{print$2}')
newpid=$(who -u | grep "$pts " | awk '{print$7}')
cat idlegood | grep -v "$newpid" > oldpids
while read PID; do kill -9 $PID; done < oldpids
fi
after that part it executes the main program all the users run.
It seems to work but every now and then one of the user accounts that uses this profile script will open up another session anyway.
As you can see, I am a beginner and I am sure there is a much more elegant way to do this, but I am still learning. Can anyone tell me why it could be that it works for most users but not others?
Thanks