0

I get an error with this script when trying to send a message to slack using curl in LUA. Thanks for your help.

cmd="c:\\curl\\bin\\curl.exe -X POST -H "Content-type: application/json" -d "{\"text\":\"Hello\"}" https://hooks.slack.com/services/xxxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxx"

LUA_ERROR:[string "cmd="c:\curl\bin\curl.exe -X POST -H "Content-type: applicat..."]:1: =' expected near -'

1 Answer 1

1

Your script is full of syntax errors because you didn't bother to escape the double quotes enclosing the arguments of your cURL command. The simplest solution is to just use long strings here, which don't require you to escape double quotes while not interpreting \" as ", thus preserving your inner escapes:

cmd=[[c:\curl\bin\curl.exe -X POST -H "Content-type: application/json" -d "{\"text\":\"Hello\"}" https://hooks.slack.com/services/xxxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxx]]

alternatively you could use single quotes, requiring you to escape all backslashes:

cmd='c:\\curl\\bin\\curl.exe -X POST -H "Content-type: application/json" -d "{\\"text\\":\\"Hello\\"}" https://hooks.slack.com/services/xxxxxxxxxx/xxxxxxxxx/xxxxxxxxxxxxx'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.