The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: checking uid
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-19-2007
filthymonk filthymonk is offline
Registered User
  
 

Join Date: May 2007
Posts: 59
checking uid

How do i go about getting the uid of the user and verify ?


Code:
if [ $uid != 'root' ] 
then 
        echo "You are not a superuser, please login as a superuser"
        exit1; 
fi

the above code doesn't work. can some guru please help me.
1. how to get the uid of the user ? i know by typing id but how to get the script to verify its a su?
2. how do i exit the whole script if he/she is not a su?
3. Is the above, able to continue the rest of the process if its a su?

-Thanks & Regards-