【问题标题】:how to escape this curl command to be used by LUA os.execute?如何转义 LUA os.execute 使用的 curl 命令?
【发布时间】:2014-12-09 20:01:30
【问题描述】:

如何转义这个 curl 命令字符串以供 LUA os.execute 使用?

curl -u mytokenkey: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Note Title", "body": "Note Body\nSecond Line\n  http://goggle.com/ "}'

注意:我确实寻找了一个可以在这里使用的 LUA 库,但我发现的那些是用 c 代码编写的,而不是一个易于使用('需要')基于 LUA 的库......

【问题讨论】:

    标签: curl lua escaping


    【解决方案1】:

    写成一个长字符串:

    command=[[
    curl -u mytokenkey: -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Note Title", "body": "Note Body\nSecond Line\n  http://goggle.com/ "}'
    ]]
    

    【讨论】:

    • 好主意 - 我已经尝试过了,但它似乎没有用 - 问题也是我不确定如何让响应字符串返回以查看它??
    • @Greg,使用io.popen 而不是os.execute,但这是一个单独的问题。
    猜你喜欢
    • 2014-02-11
    • 1970-01-01
    • 2012-10-27
    • 2021-10-27
    • 2012-03-29
    • 2012-12-13
    • 2013-02-04
    • 1970-01-01
    • 2021-06-27
    相关资源
    最近更新 更多