You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用AWS CLI向ElasticMQ本地SQS发送JSON消息报错,如何解决?

解决AWS CLI发送JSON消息体的zsh解析错误

出现zsh: parse error near '}'是因为zsh会将JSON中的{、}和空格当作shell语法解析,而非消息体的一部分。可以通过以下两种方式解决:

方法1:用单引号包裹JSON消息体

将整个JSON字符串用单引号包裹,单引号会阻止shell解析内部特殊字符,直接把完整JSON传递给AWS CLI:

aws --region=us-west-2 --endpoint=http://localhost:9324 sqs send-message --queue-url http://localhost:9324/000000000000/jobs --message-body '{"FileHashes": ["79054025255fb1a26e4bc422aef54eb4"] }'

方法2:通过文件传递JSON消息体

如果JSON内容复杂或较长,建议将其写入单独文件,再通过file://路径引用:

  1. 创建包含JSON内容的文件(例如job-message.json):
{"FileHashes": ["79054025255fb1a26e4bc422aef54eb4"] }
  1. 执行AWS CLI命令引用该文件:
aws --region=us-west-2 --endpoint=http://localhost:9324 sqs send-message --queue-url http://localhost:9324/000000000000/jobs --message-body file://job-message.json

内容的提问来源于stack exchange,提问作者Anthony

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 22:01:00