This is actually sort of a shell script question… but if there’s an answer in Applescript, they can be combined, of course.
I have the following script:
echo ‘newadmin::512:512::0:0:NewAdmin:/Users/newadmin:/bin/bash’ | niload passwd /
echo ‘newadmin:*:512:newadmin’ | niload group /
niutil -appendprop / /groups/admin users newadmin
ditto /Users/oldadmin /Users/newadmin
chown -R newadmin:admin /Users/newadmin
It creates a new account (newadmin) and then clones the home folder from an existing admin account (oldadmin). The reason for doing this is that the admin accounts are setup differently from the standard user accounts and I want the newadmin account to be like the oldadmin account.
The new admin account gets created with a blank password in this script. I want to assign a password but cannot find a way to do it. The second term in the first line (between newadmin: and :512) is supposed to represent the password. If I enter something there, a password does appear to get set but it is not interpreted as a string (I tried ‘111’, no quotes, but ‘111’ didn’t work as the password when I tried to login.)
I’ve also played with the command passwd but I can’t figure out how to pipe the password I want it to set within the script. I tried:
echo ‘111’ | passwd newadmin
but no dice.
Any help and suggestions would be appreciated.