From csh script, how to know if logged in as root?

I know that when I'm logged in as root in (Solaris or Linux), I would get the # sign at the terminal screen.

But from a csh script, how do I know if I'm running that script logged in as root or not?

You could add the following to your script:

echo `whoami`
sleep 5

However, from an administrative point of view, if you are not sure if you are running that script as root, you probably should not be running that script as root.

Just guessing - but aren't there any built-in variables and/or commands availably you could query, approximately as follows:

if [ $UID == 0 ]
if [ $USER == 'root' ]
if [ $( whoami ) == "root" ]

Test $LOGNAME .