在CURL中展开变量 [英] expanding variable in CURL
本文介绍了在CURL中展开变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下curl语句在我的shell脚本中正常工作。
curl -Ld'username = user& password = password& source = oksoft& dmobile ='$ mnumber'& message = Slave正在运行OK'http://167.123.129.195/smsclient//api.php
手机号码按预期展开。但是当我使用一个变量作为消息参数时,我得到$ myvar输出而不是展开的变量。
curl -Ld' username = user& password = password& source = oksoft& dmobile ='$ mnumber'& message =$ myvar'http://167.123.129.195/smsclient//api.php
$ c $ 解决方案
div>
单引号抑制扩展。切换引号。
curl ...'...'$ myvar'...'。 ..
The following curl statement works OK in my shell script.
curl -Ld'username=user&password=password&source=oksoft&dmobile='$mnumber'&message=Slave is working OK' http://167.123.129.195/smsclient//api.php
The Mobile number is expanded as expected. But when I use a variable for the message parameter, I get $myvar output instead of the expanded variable.
curl -Ld'username=user&password=password&source=oksoft&dmobile='$mnumber'&message="$myvar"' http://167.123.129.195/smsclient//api.php
How do I use the variable for the message?
解决方案 Single quotes inhibit expansion. Switch up the quotes.
curl ...'..."'"$myvar"'"...'...
这篇关于在CURL中展开变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文