我正在尝试使用来自 Linux shell 脚本的 CURL POST 到 SMS 提供商 (Sybase 365) 的 HTTP 网关。
我需要传递以下数据(注意 [ ] 和 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]
我能做些什么来避免这种情况,还是我需要一个替代工具?
我正在使用包含我的数据的文件进行测试,但我想在实践中避免这种情况并直接从脚本中发布。
最佳答案
尝试使用 --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
可能仍然值得一试。
关于linux - 如何使用 curl 命令行工具发布 LF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/388365/