Im using curl against a webapi which knows to return a file for a particular post request (running this within browser would trigger the browser to pop up a "save file" dialog) . My intention is to have the response bytes written to a file. I use the following command
curl -k -i -u username:password -X POST -H "Content-Type:application/json" -d @c:\\curl\\request_body_file.json -o config.cfg https://127.0.0.1:8000/myapi/trigger/export
This however causes also the response header to be written to the output file, which is not my desire. I only need the response content saved.
This is how the output file looks like :
TTP/1.1 200 OK
Content-Length: 12042
Content-Type: application/octet-stream; charset=UTF-8
Content-Disposition: attachment; filename=my_export
Date: Wed, 23 Oct 2013 09:30:47 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.1.2
X-Auth-Token: Token ODVhMzk3OWY1NjcwMjg2ZGM0MDhmNTEzYTYwZmE4M2JhNTM1YmE0Yw==
xÚíÝÛãX~ØqÍÎŽçvfvervrevtrbyewd3334444 ................................
How would the curl command look in order to achive what I previously described.
Thanks
Like in: curl http://{one,two}.site.com -o "file_#1. txt" or use several variables like: curl http://{site,host}.host[1-5].com -o "#1_#2" You may use this option as many times as the number of URLs you have. See also the --create-dirs option to create the local directories dynamically.
By default, curl prints the response to screen. To make it save the response to a file, use the -o file command line option.
cURL commands can download files from a remote location. You can do it in two different ways: -O will save the file in the current working directory with the same file name as remote. -o lets you specify a different file name or location.
You could simply append the output to a file
curl ... >> output-file.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With