Computing.Net > Forums > Unix > test users from a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

test users from a file

Reply to Message Icon

Name: Hamim
Date: November 3, 2003 at 06:03:49 Pacific
OS: Sco Openserver
CPU/Ram: pentium 2
Comment:

Hi
I want to know how to do a test for users
eg: a file called pals & in it I have a list of users.
I want to :
while test $1
do if test $1 != "pals"
then
do something
fi



Sponsored Link
Ads by Google

Response Number 1
Name: Frank
Date: November 4, 2003 at 02:03:24 Pacific
Reply:

Not sure if I understood you correctly,

ok first you have a file called pals
e.g.
frank
david
lucas

and you would like to read the content of the file

{ while read user
do
if [ $user != frank ]
then
echo "Du bist nicht Frank aber $user"
else
echo "Du bist Frank"
fi
done } < pals

hope I got your question right.

No Risk no fun
Frank


0

Response Number 2
Name: Hamim
Date: November 4, 2003 at 06:39:17 Pacific
Reply:

Currently i am using this scirpt:
set `who -u`
while test $1
do if test $1 != "root"
then
tm=$6
procid=$7
case $tm in
.) ;;
0:*) ;;
1:*) ;;
*) kill -9 $procid
esac
fi
shift;shift;shift;shift;shift;shift;shift
done

I need to have more than root excluded from being killed -thats why I want to have a file called "pals" to include users not to be killed

Thanks
Hamim


0

Response Number 3
Name: nails
Date: November 4, 2003 at 12:55:49 Pacific
Reply:

Hamim:

You have a logic problem. You can't do this:

set `who -u`

but you can do this:

`who -u` > data.file

Then read data file with your loop

while read line
do
set $line
.
.
done < data.file
# end stub

Regards,

Nails



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: test users from a file

input to a program from a file www.computing.net/answers/unix/input-to-a-program-from-a-file/5021.html

Extracting information from a file www.computing.net/answers/unix/extracting-information-from-a-file/7770.html

reading from a file in unix www.computing.net/answers/unix/reading-from-a-file-in-unix/7355.html