加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何使用curl命令行工具POST LF?

发布时间:2020-12-13 18:49:19 所属栏目:Linux 来源:网络整理
导读:我正在尝试使用来自 Linux shell脚本的CURL POST到SMS提供程序的HTTP网关(Sybase 365). 我需要传递以下数据(注意[]和LF字符) [MSISDN]List=+12345678[MESSAGE]Text=Hello[END] 如果我使用-F参数提交文件,CURL将删除LF,例如 curl -F @myfile "http://www.syba
我正在尝试使用来自 Linux shell脚本的CURL POST到SMS提供程序的HTTP网关(Sybase 365).

我需要传递以下数据(注意[]和LF字符)

[MSISDN]
List=+12345678
[MESSAGE]
Text=Hello
[END]

如果我使用-F参数提交文件,CURL将删除LF,例如

curl -F @myfile "http://www.sybase.com/..."

在服务器上导致此结果(被拒绝)

[MSISDN]List=+12345678[MESSAGE]Text=Hello[END]

我有什么办法可以避免这种情况,还是需要替代工具?

我正在使用包含我的数据的文件进行测试,但我想在实践中避免这种情况,直接从脚本中进行POST.

解决方法

尝试使用–data-binary而不是-d(ata-ascii).

从手册:

–data-binary (HTTP) This posts data in a similar manner as –data-ascii does,although when using this option the entire context of the posted data is kept as-is.

If you want to post a binary file without the strip-newlines feature of the –data-ascii option,this is for you. If this option is used several times,the ones following the first will append data.

ETA:哎呀,我应该更仔细地阅读这个问题.你使用的是-F,而不是-d.但是–data-binary可能仍然值得一试.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读