LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 10: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 01:40 PM. Reason: domain data removed
 
Old 07-12-2010, 03:38 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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 03:39 PM.
 
Old 07-13-2010, 08:31 AM   #3
bl651
LQ Newbie
 
Registered: Jul 2010
Posts: 2

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


Reply



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 04: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 11:42 AM
Problem using Curl srihariv Linux - General 2 03-17-2008 06:53 AM
script to parse variables to curl script and execute morphix Programming 17 11-30-2007 01:27 AM
Threads synchronisation problem (mutex variables and contitional variables) zahadumy Programming 6 12-07-2005 12:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:15 AM.

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
Open Source Consulting | Domain Registration