View Single Post
Old 25th March 2006, 17:15
sbovisjb1 sbovisjb1 is offline
Senior Member
Join Date: Feb 2006
Posts: 176
Thanks: 0
Thanked 1 Time in 1 Post
Default script for it

When run by itself, whoami looks like this:
$ whoami

That should be sufficient to give you the clue on how to implement the test you seek:
if [ $(whoami) = "sbovisjb1" ]
execute the code, we're the right user
echo "You must be user 'joe' to run this script."
exit 0

You can modify this to match the user or set of users you want to allow, or you can negate the logic to screen out bad userIDs immediately, like this:
if [ $(whoami) = "root" ]
echo "You cannot run this script as root."
exit 1

original source:
Reply With Quote