Q: Problem with creating a plist file using AppleScript (defaults)
Question 1
I am trying to use this script:
do shell script "defaults write ~/Desktop/com.test Directory1 \"<dict><key>Directory2</key><dict>\\ <key>Directory3</key><dict>\\ <key>Number1</key><integer>1</integer>\\ <key>String1</key><string>String1</string>\\ <key>Boolean1</key><bool>TRUE</bool>\\ </dict></dict></dict></dict>\";"
to create a plist file that will look like this:
However, the script will return this error:
error "2014-05-06 12:38:26.927 defaults[3003:f07] Could not parse: <dict><key>Directory2</key><dict><key>Directory3</key><dict><key>Number1</key>< integer>1</integer><key>String1</key><string>String1</string><key>Boolean1</key> <bool></bool></dict></dict></dict></dict>. Try single-quoting it." number 1
as soon as I try to add Boolean1. If I remove this line from the script:
<key>Boolean1</key><bool>TRUE</bool>\\
the script will work and create a com.test.plist file on the Desktop that will look like on the screenshot above, but (of course) with no boolean. What am I doing wrong?
Question 2
How can I read the value of "Number1" using Terminal? How should the "defaults read" command look like?
OS X Mavericks (10.9.2)
Posted on May 6, 2014 3:51 AM
Please ignore the first question. The code should look like this:
do shell script "defaults write ~/Desktop/com.test Directory1 \"<dict><key>Directory2</key><dict>\\
<key>Directory3</key><dict>\\
<key>Number1</key><integer>1</integer>\\
<key>String1</key><string>String1</string>\\
<key>Boolean1</key><true/>\\
</dict></dict></dict>\";"
Posted on May 6, 2014 5:37 AM
