LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-12-2010, 11:53 AM   #1
bl651
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
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.

Last edited by Tinkster; 07-12-2010 at 02:40 PM. Reason: domain data removed
 
Old 07-12-2010, 04:38 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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.

Last edited by David the H.; 07-12-2010 at 04:39 PM.
 
Old 07-13-2010, 09:31 AM   #3
bl651
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks a lot. It worked fine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH variables, quotation marks and cURL struggles matthias_k Programming 13 01-27-2013 05:56 PM
cURL: Server has many IPs, how would I make a cURL script use those IPs to send data? guest Programming 0 04-11-2009 12:42 PM
Problem using Curl srihariv Linux - General 2 03-17-2008 07:53 AM
script to parse variables to curl script and execute morphix Programming 17 11-30-2007 02:27 AM
Threads synchronisation problem (mutex variables and contitional variables) zahadumy Programming 6 12-07-2005 01:30 PM


All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration