Batch File cURL – How to Capture cURL Output to a File

batch-filecurl

I have a text document that contains a bunch of URLs in this format:

URL = "sitehere.com"

What I'm looking to do is to run curl -K myfile.txt, and get the output of the response cURL returns, into a file.

How can I do this?

Best Answer

curl -K myconfig.txt -o output.txt 

Writes the first output received in the file you specify (overwrites if an old one exists).

curl -K myconfig.txt >> output.txt

Appends all output you receive to the specified file.

Note: The -K is optional.

If you are posting to a URL like https://example.org/?foo=1&baz=4 then you need to put double quotes around the URL:

curl -X POST -H "Content-Type: application/octet-stream" --data-binary "@/home/path/file.xyz" "https://xample.org:8080/v1/?filename=file.xyz&food=1&z=bee" >out.txt 2>err.txt
Related Question