Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Revised script...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Revised script...
Authored by: Cap'n Hector on May 28, '04 09:36:32AM
I threw this adduser script together that shouldn't suffer the same issues as the one described above:
echo "Enter username:"
read u_name
echo "Enter the full name for user $u_name's:"
read real_name
echo "Is $u_name to be an Admin user (y/N)?"
read if_admin
new_uid=`nidump passwd . | awk -F: '{print $3f}' | sort -n | tail -1`
new_uid=`expr $NUID + 1`
nicl . -create /users/$u_name
nicl . -create /users/$u_name uid $new_uid
nicl . -create /users/$u_name realname "$real_name"
nicl . -create /users/$u_name passwd ""
nicl . -create /users/$u_name gid 20
nicl . -create /users/$u_name shell "/bin/tcsh"
nicl . -create /users/$u_name home "/Users/$u_name"
nicl . -create /users/$u_name _writers_passwd $u_name

passwd $u_name

ditto /System/Library/UserTemplate/English.lproj /Users/$u_name
chown -R $u_name:staff /Users/$u_name

nicl . -read /users/$u_name
if [ "$if_admin" = Y -o "$if_admin" = y ]
    nicl . -append /groups/wheel users $u_name
    nicl . -append /groups/admin users $u_name
    nicl . -read /groups/wheel
    nicl . -read /groups/admin
Paste it into a text document, save it somewhere in your $PATH, chmod it 755, and then you can run it. Note that it does require admin access to create a new user.

[ Reply to This | # ]
Revised script...
Authored by: baronworm on Jul 01, '04 11:27:27AM

there is a simple, but important, typo in that script.

To fix, change this line:

new_uid=`expr $NUID + 1`

to instead read:

new_uid=`expr $new_uid + 1`

[ Reply to This | # ]