Question about writing preference file upon login...

Hello all.

I am trying to figure out if this would be fairly easy and robust and how to do it…Unfortunately I’m a bit (as in very) green to applescript and shell scripting.

I have a number of macs running 10.4.8 and authenticating against Active Directory…no os x servers, but hopefully soon. Whenever a user logs into a computer, it creates their mobile home directory. The issue is that I have to go to every machine and setup extensis suitcase for them since it requires that they have the proper username.

I can get their username from the command line using whoami. I can also write the proper username with the command
defaults write com.extensis.Suitcase “user name” my_user. I also have the font server address and status (active or not) but those are static values that should be easy to set once I have a format to follow.

What I would like to do is first populate the preference file with their username at login using the results of the whoami command. If anyone would be willing to help out, I’d love to get started on this!


Sorry to reply to my own post…I am starting to make some slow progress, but it’s good learning…

I have this so far, but it does not quite work…

set user to do shell script "whoami"
do shell script "defaults write com.extensis.Suitcase3 user name" & user
display dialog "Set it to " & user

the result should look like

when using defaults write from the command line, I have to use quotes around the user name only. Eg.
defaults write com.extensis.Suitcase3 “user name” b_bob

I’ve tried putting a space in but that gives me an errror…
do shell script "defaults write com.extensis.Suitcase3 user name " & user

Applescript Error
2007-02-22 09:40:13.804 defaults[1488] Unexpected argument a_robinson; leaving defaults unchanged.

This must be something simple…

Try one of these:

do shell script "/usr/bin/defaults write com.extensis.Suitcase3 'user name' \"$(/usr/bin/whoami)\""
do shell script "/usr/bin/whoami"
do shell script "/usr/bin/defaults write com.extensis.Suitcase3 'user name' " & quoted form of result