LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem Using Variables In CURL (https://www.linuxquestions.org/questions/linux-newbie-8/problem-using-variables-in-curl-819424/)

bl651 07-12-2010 10:53 AM

Problem Using Variables In CURL
 
Hi, I need some help using variables in CURL.

Here's my code:

transfer_to_pcid="AAAAAAAA"
transfer_from_pcid="BBBBBBBB"
basic_password=`ssh rsync@some_test_domain 'curl --silent "http://some_test_domain/insite_com/qs2_pwd_insite_basic.asp?ST=New&PC="$transfer_from_pcid"&TP="$transfer_to_pcid"&VT=7.4"'` ;

When the command runs the variables don't seem to be getting passed to the asp page. Any help would be appreciated.

David the H. 07-12-2010 03:38 PM

The curl command is enclosed in single-quotes, which disables the special meanings of all other characters, including " (and of course $). You can either "un-enclose" the variables (and re-enclose them in double-quotes if necessary), or else use double-quotes on the outside, and escape the internal double-quotes.

Code:

basic_password=$(ssh rsync@some_test_domain 'curl --silent "http://some_test_domain/insite_com/qs2_pwd_insite_basic.asp?ST=New&PC='"$transfer_from_pcid"'&TP='"$transfer_to_pcid"'&VT=7.4"')

or

basic_password=$(ssh rsync@some_test_domain "curl --silent \"http://some_test_domain/insite_com/qs2_pwd_insite_basic.asp?ST=New&PC=$transfer_from_pcid&TP=$transfer_to_pcid&VT=7.4\"")

(I hope I got that right :))

Note also that $(..) is preferred over `..`.

PS: Please use [code][/code] tags around your code, to help preserve formatting and to improve readability.

bl651 07-13-2010 08:31 AM

Thanks a lot. It worked fine.


All times are GMT -5. The time now is 11:55 PM.