【问题标题】:Shell script : Executing a long lineShell 脚本:执行长行
【发布时间】:2014-05-15 11:36:03
【问题描述】:

我正在编写一个 shell 脚本,它在最后运行一个 curl 命令发布一个 json 数据。这个数据太长,运行脚本时,它无法运行完整的命令!我试图拆分行,但在 json 数据中出现错误!

注意:我使用的是嵌入式 linux

【问题讨论】:

  • 显示 curl 命令。
  • curl xxxxxxxx --header 'Content-Type:application/json' --data '{"xxx":"'"$xxx"'","xxx":"'"$ xxx"'","xxx":"'"$xxx"'","xxx":"'"$xxx"'","xxxx":"'"$xxx"'","xxx":"' "$xxxx"'","xxxx":{"xxxx":"'"$xxx"'","xxx":"'"$xxx"'","xxxx":"'"$xxx"'" ,"xxx":"'"$xxx"'","xxx":"'"$xxxx"'","xxx":"'"$xxx"'", "xxxx":"'"$xxx" '","xxx":"'"$xxx"'"}'

标签: shell split command-line-arguments


【解决方案1】:

你能把你的 JSON 数据写到一个文件中,然后像这样调用 curl:

curl "$URL" --header 'Content-Type:application/json' --data @data.json

【讨论】:

  • 我试过了,但也没有用!我应该在这个文件中准确地写什么? ('{xxxxxxxxxxxxx}') ?
猜你喜欢
  • 2014-03-26
  • 1970-01-01
  • 2013-06-13
  • 1970-01-01
  • 2020-09-15
  • 2010-12-01
  • 2016-07-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多