Why does "dscl . -change /Users/wick RealName" do the job in Terminal but not in ScriptEditor?

473 views Asked by At
root# dscl . -change /Users/default RealName "Brian" "David"

When running this command in Terminal the Full Name of the user that is associated with home folder "default" is changed from Brian to David.

However when I try to run this command in ScriptEditor I get a syntax error.

do shell script "dscl . -change /Users/default RealName "Brian" "David""

Syntax Error
Any ideas as to how I could correct this ?

1

There are 1 answers

1
vadian On BEST ANSWER

The second double quote breaks the syntax because it indicates the end of the literal shell script argument. You can even see it in the source text (syntax highlighting).

I guess the double quotes around the names are not needed so it's simply

do shell script "dscl . -change /Users/default RealName Brian David"

However if the double quotes are required you have to escape them

do shell script "dscl . -change /Users/default RealName \"Brian\" \"David\""