Is it possible to direct this output from cURL into a file?
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1354 100 1354 0 0 17358 0 --:--:-- --:--:-- --:--:-- 17358
100 67081 100 67081 0 0 68171 0 --:--:-- --:--:-- --:--:-- 4031k
I cannot find anything in --help
that would indicate you can. -o
just done the response from what I can tell.
I am just wanting to know if the request succeded and how long it took.
For those of you want to copy the cURL output in the clipboard instead of outputting to a file, you can use pbcopy by using the pipe | after the cURL command. Example: curl https://www.google.com/robots.txt | pbcopy . This will copy all the content from the given URL to your clipboard.
To download a file with Curl, use the --output or -o command-line option. This option allows you to save the downloaded file to a local drive under the specified name. If you want the uploaded file to be saved under the same name as in the URL, use the --remote-name or -O command line option.
curl lets you quickly download files from a remote system. curl supports many different protocols and can also make more complex web requests, including interacting with remote APIs to send and receive data.
Use "-C -" to tell curl to automatically find out where/how to resume the transfer. It then uses the given output/input files to figure that out. If this option is used several times, the last one will be used. When used in conjunction with the -o option, curl creates the necessary local directory hierarchy as needed.
This output is sent to stderr. So, to get it all you need is redirect stream 2 (stderr) to a file as
curl -o responseFile.html http://www.somewhere.com 2> informationFile.txt
But, as your capture shows, times are not always included.
The better option to know if the request succeded and how long it took is to ask curl to output some internal variables. This is done with the -w
switch. So, your command should look as
curl -o responseFile.html http://www.somewhere.com -w "%{response_code};%{time_total}" > dataFile.txt 2> informationFile.txt
That way, the response will go to responseFile.html (or whatever you need), the progress information (stderr or stream 2) will go to informationFile.txt and the required request response code and time information will go to dataFile.txt
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