I run this command in a single bash file to post the data to a url and get the response
curl -s -X POST $url -d "username=username"
It outputs the response body. All good But I want to automate this task so I have saved many URLs in a file called urls.txt which looks like this:
https://url1.com
https://url2.com
and so on...
To loop all the lines(url's) in the file I run this script
while IFS="" read -r p || [ -n "$p" ]
do
curl -s -X POST $p -d "username=username" >> output.txt
done < urls.txt
I even try to run the loop with a hardcoded url, and it still doesn't work:
while IFS="" read -r p || [ -n "$p" ]
do
curl -s -X POST http://manual.url -d "username=username" >> output.txt
done < urls.txt
But I get no output saved or displayed. I don't know why is that. Any ideas? Can't I run curl in a snoop-a-loop?
-s
("silent") option and don't redirect into a file? Do you get the correct output in the terminal? What if you properly put the URL last on the command line and double quote it?