Executing multiple cURL requests with different parameters - Throws -bash: syntax error near unexpected token `('

I'm doing multiple cURL request like this one:

curl 'http://www.website.com/app/application' -H 'Cookie: _cb_ls=1; em_cdn_uid=t%3D1463525134354%26u%3D86461fb6689e46c4a62881ce3357cbcc; em_p_uid=l:1463668963788|t:1463525135884|u:f3d8947c76024450885843f258571c45; __auc=b15c4507154c0e31047b3844aa7; _cb=CVUoIeDh7JhxCGgn1b; _chartbeat2=.1463525007080.1465845135479.0000000011110001; _ga=GA1.2.1272946403.1463524985; _gat=1; __utma=158138023.1272946403.1463524985.1466007370.1466019639.16; __utmb=158138023.0.10.1466019639; __utmc=158138023; __utmz=158138023.1465409755.13.3.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmv=158138023.|1=custID=83f090439770a6e6cc0cb324504524e7=1' -H 'Origin: http://www.latercera.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: es-ES,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'X-Prototype-Version: 1.6.1' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: http://www.website.com/resultadoBusqueda.html?q=KEYWORD' --data 'action=searchSolr&type=CONTENT&siteCode=TEFURVJDRVJB&fq=taxonomyId%3A24%20AND%20status%3A2%20AND%20launchDate%3A%5B2008-05-31T23%3A59%3A59.999Z%20TO%20NOW%5D&indent=on&wt=json&qt=default&sort=launchDate%20desc&start=0&rows=15&q=KEYWORD&_=' --compressed > MyFile.txt

I'm looking in website for multiple keywords (more than 1.500), so I've changed the cURL instruction in Excel with the concat function, and the result is like this:

curl 'http://www.website.com/app/application' -H 'Cookie: _cb_ls=1; em_cdn_uid=t%3D1463525134354%26u%3D86461fb6689e46c4a62881ce3357cbcc; em_p_uid=l:1463668963788|t:1463525135884|u:f3d8947c76024450885843f258571c45; __auc=b15c4507154c0e31047b3844aa7; _cb=CVUoIeDh7JhxCGgn1b; _chartbeat2=.1463525007080.1465845135479.0000000011110001; _ga=GA1.2.1272946403.1463524985; _gat=1; __utma=158138023.1272946403.1463524985.1466007370.1466019639.16; __utmb=158138023.0.10.1466019639; __utmc=158138023; __utmz=158138023.1465409755.13.3.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmv=158138023.|1=custID=83f090439770a6e6cc0cb324504524e7=1' -H 'Origin: http://www.website.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: es-ES,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'X-Prototype-Version: 1.6.1' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: http://www.website.com/resultadoBusqueda.html?q=KEYWORD2 --data 'action=searchSolr&type=CONTENT&siteCode=TEFURVJDRVJB&fq=taxonomyId%3A24%20AND%20status%3A2%20AND%20launchDate%3A%5B2008-05-31T23%3A59%3A59.999Z%20TO%20NOW%5D&indent=on&wt=json&qt=default&sort=launchDate%20desc&start=0&rows=1000&q=KEYWORD2&_=' --compressed >> MyFile.txt;
curl 'http://www.website.com/app/application' -H 'Cookie: _cb_ls=1; em_cdn_uid=t%3D1463525134354%26u%3D86461fb6689e46c4a62881ce3357cbcc; em_p_uid=l:1463668963788|t:1463525135884|u:f3d8947c76024450885843f258571c45; __auc=b15c4507154c0e31047b3844aa7; _cb=CVUoIeDh7JhxCGgn1b; _chartbeat2=.1463525007080.1465845135479.0000000011110001; _ga=GA1.2.1272946403.1463524985; _gat=1; __utma=158138023.1272946403.1463524985.1466007370.1466019639.16; __utmb=158138023.0.10.1466019639; __utmc=158138023; __utmz=158138023.1465409755.13.3.utmcsr=facebook.com|utmccn=(referral)|utmcmd=referral|utmcct=/; __utmv=158138023.|1=custID=83f090439770a6e6cc0cb324504524e7=1' -H 'Origin: http://www.website.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: es-ES,es;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: text/javascript, text/html, application/xml, text/xml, */*' -H 'X-Prototype-Version: 1.6.1' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Referer: http://www.website.com/resultadoBusqueda.html?q=KEYWORD3 --data 'action=searchSolr&type=CONTENT&siteCode=TEFURVJDRVJB&fq=taxonomyId%3A24%20AND%20status%3A2%20AND%20launchDate%3A%5B2008-05-31T23%3A59%3A59.999Z%20TO%20NOW%5D&indent=on&wt=json&qt=default&sort=launchDate%20desc&start=0&rows=1000&q=KEYWORD3&_=' --compressed >> MyFile.txt;

After, I'm copying all the column and I pasted it in the console. But the result of the query is:

-bash: syntax error near unexpected token `('

Do you know what the problem is?

Upvotes: 0

Views: 223

Answers (1)

that other guy
that other guy

Reputation: 123480

Syntax highlighting, either in an editor or just in your post courtesy of StackOverflow, will quickly reveal the problem:

Syntax highlighted code showing unquoted literals

Here, all flags are one color while all quoted arguments are another, until suddenly they stop matching.

On closer inspection, you can see that you're missing a single quote before on the argument before --data. If you insert one, syntax highlighting again becomes consistent:

Syntax highlighted code corrected and consistently colored

Upvotes: 2

Related Questions