defaults write -data?

Every so often I need to reset a plist file and one defaults I want to replace using applescript is a data value. However when I run the script I get this:

sh: -c: line 0: syntax error near unexpected token `newline'
sh: -c: line 0: `defaults write com.company.application globalDownloadURLData -data <62706c69 73743030 d4010203 04050617 18582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0a4 07080f10 55246e75 6c6cd309 0a0b0c0d 0e562463 6c617373 5b4e532e 72656c61 74697665 574e532e 62617365 80038002 80005f10 3966696c 653a2f2f 6c6f6361 6c686f73 742f5573 6572732f 44616e69 656c2f44 65736b74 6f702f4d 79253230 53747566 662f546f 7272656e 7473d211 1213145a 24636c61 73736e61 6d655824 636c6173 73657355 4e535552 4ca21516 554e5355 524c584e 534f626a 6563745f 100f4e53 4b657965 64417263 68697665 72d1191a 54726f6f 74800108 111a232d 32373c42 49505c64 66686aa6 abb6bfc5 c8ced7e9 ecf10000 00000000 01010000 00000000 001b0000 00000000 00000000 00000000 00f3>'

As you can see the original command would be:

do shell script "defaults write com.company.application globalDownloadURLData -data <hex_key>"

Any ideas?

Hi,

keep the data string in one line and escape the spaces by quoting the whole data string e.g.
‘<62706c69 7374. .000000 00f3>’

Thanks for the reply.

When I try to keep it all in one string it still goes to a new line when it hits the edge of applescript presenting me with the same error. Also when quoting the hex value you did above, it brings up a guide of values:

etc…

What’s about to put the raw data into a variable, in my AppleScript Editor (Script Debugger) the raw data is one line


set theData to "<62706c69 73743030 d4010203 04050617 18582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0a4 07080f10 55246e75 6c6cd309 0a0b0c0d 0e562463 6c617373 5b4e532e 72656c61 74697665 574e532e 62617365 80038002 80005f10 3966696c 653a2f2f 6c6f6361 6c686f73 742f5573 6572732f 44616e69 656c2f44 65736b74 6f702f4d 79253230 53747566 662f546f 7272656e 7473d211 1213145a 24636c61 73736e61 6d655824 636c6173 73657355 4e535552 4ca21516 554e5355 524c584e 534f626a 6563745f 100f4e53 4b657965 64417263 68697665 72d1191a 54726f6f 74800108 111a232d 32373c42 49505c64 66686aa6 abb6bfc5 c8ced7e9 ecf10000 00000000 01010000 00000000 001b0000 00000000 00000000 00000000 00f3>"
do shell script "defaults write com.company.application globalDownloadURLData -data " & quoted form of theData

I downloaded Script Debugger and indeed it came out in one long line however upon running it, the same error was produced even with your quote form.

Then remove the < > characters from the literal data string and try


do shell script "defaults write com.company.application globalDownloadURLData -data <" & quoted form of theData & ">"

Afraid that took me back to my first post: