The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > OS X (Apple)
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-14-2008
[MA]Flying_Meat [MA]Flying_Meat is offline
Registered User
 

Join Date: Sep 2002
Location: San Fran
Posts: 108
Who will be running the interactive user add script? make the script executable by root and no one else. The person issuing the command (launching the script) will need "sudo" privileges, which all local admins accounts have by default.

Here is a page that will help you with the dscl commands:
Porting UNIX/Linux Applications to Mac OS X: Open Directory and the dscl Tool

10.4.x can use dscl too. Might as well use it if you aren't expecting to support the same function in 10.3.

You will basically poll the user for data, and store that data in a variable with the "read" command, for use in making decisions and issuing commands based on the users input.

Some interactive considerations:
echo "Enter a username: "
read username

echo "Add $username? (y/n):
read addflag


Test $addflag, then make the script check if the user already exists. and inform the user if so.

You can use the scripts variable $username where ever a username is required.

Don't take anything for granted. It is possible to add a username to the admin group multiple times, which, while it might not be catastrophic, is very messy. So test, test, test, deploy (but only if you feel it's been tested enough )
Reply With Quote