【发布时间】:2015-03-17 15:21:07
【问题描述】:
我使用下面这行来创建数据库:
curl -X POST 'http://10.1.1.1:8086/db?u=root&p=root' -d '{name: test1}
如果我尝试从 shell 脚本中执行此操作:
ip=10.1.1.1
curl -X POST 'http://$ip:8086/db?u=root&p=root' -d '{name: test1}'
如果我尝试在双配额内使用它们,我在单配额内替换 shell 变量时遇到问题:
curl -X POST "http://$ip:8086/db?u=root&p=root" -d '{name: test1}'
变量扩展为正确的值,在终端打印
curl -X POST "http://10.1.21.1:8086/db?u=root&p=root" -d '{name: test1}': **No such file or directory**
这个问题的正确解决方案是什么?
【问题讨论】:
-
也许我误读了,但您的实际问题是什么?为什么它只适用于双引号?
-
您如何使用
curl?显示脚本的相关部分。