Bash – loop curl get request bash

bashcontrol flowcurl

I'm trying to automate a curl script and eventually make it loop also. I found that I can't use any loop like:

for i in `cat authors`
do
    curl *line here*   "www.test.com/autors?string="$i"&proc=39"
etc

or even env glob variables for CURL

Is there a way to loop a get request on curl for one variable?

curl -H "Host: www.test.com" -G "www.test.com/autors?string="author+name"&proc=39"

All I get is the traffic graph CURL has and no good result. I'm using bash

Best Answer

Try this construct instead:

 while read author; do
      curl "http://www.test.com/authors?string=$author&proc=39"
 done < authors

This will save you the cat, having to do things in backticks, etc. It would also allow you to read several columns out of the input file if you wanted to, but specifying just one variable to fetch like in my example will get the whole line.

Related Question