Computing.Net > Forums > Unix > check for logins in file & execute

check for logins in file & execute

Reply to Message Icon

Original Message
Name: Hamim
Date: July 25, 2003 at 02:19:57 Pacific
Subject: check for logins in file & execute
OS: Sco openserver 505
CPU/Ram: pentium 2/512kb
Comment:

set `who -u`
while test $1
do if test -r != "root"
then
tm=$6
procid=$7
case $tm in
.) ;;
0:*) ;;
1:*) ;;
*) kill -9 $procid
esac
fi
shift;shift;shift;shift;shift;shift;shift;
done
How do I check for more than root ,so that the script does not kill that login.
eg I want the script to first check the file in a dir to see if logins exist (dont kill) before it executes the script.
THanks
Hamim


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: July 25, 2003 at 09:13:09 Pacific
Reply: (edit)

Hamim:

I'm not clear what you are trying to do, but I think your basic logic is flawed. Don't you want to pipe the output of 'who -u' to a while loop parsing each line?

#!/bin/ksh

who -u| while txtline=$(line); do
set -- `echo $txtline`
echo $1
done
# end script

Regards,

Nails



Report Offensive Follow Up For Removal

Response Number 2
Name: Hamim
Date: July 29, 2003 at 01:44:24 Pacific
Reply: (edit)

I actually want my script to search a file in a directory eg: /tmp/pals
in pals I will list all logins I donot want to kill with my script.
At the moment it will only ignore "root",hence do if test -r != "root"

Thanks
Hamim


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: check for logins in file & execute 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge