curl - Nested quotation marks in "do shell script"-command cause error -
i'm running curl shell script (indesign) extendscript jsx-file.
this works simple queries, in command below can see i'm having quite quotation nesting, seem making command fail! it's not throwing errors, wordpress-post not being changed!
var command = 'do shell script "curl -x put -h \'content-type: application/json\' -d \' { \'title\': \'blub\', \'content_raw\': \'updated post content\' } \' -u username:password http://website.com/wp-json/wp/v2/cpt/12/"'; var response = app.doscript(command, scriptlanguage.applescript_language);
when write throws error, because of false quotations:
var command = 'do shell script "curl -x put -h \"content-type: application/json\" -d \" { \"title\": \"blub\", \"content_raw\": \"updated post content\" } \" -u admin:password http://seebook.dev/wp-json/wp/v2/calendar/12/"';
when run command directly in terminal, works...
curl -x put -h "content-type: application/json" -d " { \"title\": \"updates title\", \"content_raw\": \"updated post content\" } " -u username:password http://website.com/wp-json/wp/v2/cpt/12/
so version:
var command = 'do shell script "curl -x put -h \"content-type: application/json\" -d \" { \'title\': \'blub\', \'content_raw\': \'updated post content\' } \" -u username:password http://website.com/wp-json/wp/v2/cpt/12/"';
how can write query, works?
i guess that's quite noob question, i've never had such situation before...
all best, lukas
try this, outer quotes must double quotes, content-type
part enclosed in single quotes , query created quoted form of
expression
set query "{ \"title\": \"updates title\", \"content_raw\": \"updated post content\" }" shell script "curl -x put -h 'content-type: application/json' -d " & quoted form of query & " -u username:password http://website.com/wp-json/wp/v2/cpt/12/"
Comments
Post a Comment