通过变量在shell脚本curl命令
问题说明
我有一个curl命令:
I have a curl command:
curl -u ${USER_ID}:${PASSWORD} -X GET 'http://lppma670.gso.aexp.com:8080/rest/job-execution/job-details/${job_id}'
变量作业ID
中有一个值,也就是说,1160当我在shell中执行curl命令它给了我以下错误:
The variable job_id
has a value in it, say, 1160. When I execute the curl command in shell it gives me the following error:
{"message":"Sorry. An unexpected error occured.", "stacktrace":"Bad Request. The request could not be understood by the server due to malformed syntax."}
如果我通过直接数字1160中的命令,如下图所示,curl命令的作品。
If I pass the number '1160' directly in the command, as shown below, the curl command works.
curl -u ${USER_ID}:${PASSWORD} -X GET 'http://lppma670.gso.aexp.com:8080/rest/job-execution/job-details/1160'
有人可以帮助我吗?我想能够通过在curl命令变量的值。
Can someone please help me out? I wanna be able to pass the value of the variable in the curl command.
正确答案
在使用变量的外壳,你只能使用双引号,而不是单引号:单引号里面的变量没有扩大。
学习之间的区别和`。请参见 http://mywiki.wooledge.org/Quotes 并的http://wiki.bash-hackers.org/syntax/words
When using variables in shell, you can only use doubles quotes, not single quotes : the variables inside single quotes are not expanded. Learn the difference between ' and " and `. See http://mywiki.wooledge.org/Quotes and http://wiki.bash-hackers.org/syntax/words
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcgajkf
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20