Test for root.

Kevin Buettner plug-discuss@lists.PLUG.phoenix.az.us
Thu, 6 Sep 2001 17:29:27 -0700


On Sep 6,  5:07pm, Carl Parrish wrote:

> Okay I'm writting a script that tests for root status. like so
> 
> test `whoami` = 'root' || echo "You must be root to execute the commands."
> 
> it never seems to be able to pass the test. From the command line I can run whoami and get back root but it never works in the script. 
> Any idea what I'm doing wrong? 

I don't think you're doing anything wrong; it works for me...

However, even if you do get the above working, you might want to
instead consider checking against either $UID or $EUID...

Kevin