The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > OS X (Apple)
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-01-2009
xbin xbin is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 5
Try this code:

Code:
sudo -p "Please enter you admin password: " whoami 1>/dev/null && {sudo whoami;sudo whoami;whoami;sudo -k}
Let sudo do the work instead of doubling the effort. Note if the user fails to type their correct admin password or is not an admin user nothing else will run. Each command run as root must be preference with sudo. sudo -k will remove the timestamp so no other sudo commands will run without authentication.