Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save curl download statistics / log

I'm reading a stream with curl and grep some highlights.

curl url | grep desired_key_word

I've noticed that curl is providing me some nice download statistics such as:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.9M    0 10.9M    0     0  1008k      0 --:--:--  0:00:11 --:--:-- 1092k

How can I save those statistics e.g. every second in a file?

I found this: http://curl.haxx.se/mail/archive-2002-11/0115.html however it was not able to abstract it to my problem.

curl -n agent.mtconnect.org/sample\?interval=0 -o xml_stream.log 2>> dl.log

The dl.log should have the statistics included, however is does not work.

like image 316
wiesson Avatar asked Mar 17 '14 23:03

wiesson


1 Answers

Here is the unabstracted version.

curl -s -S -n http://speedtest.fremont.linode.com/100MB-fremont.bin -o /dev/null -w "%{time_total},%{size_download},%{speed_download}\n" >> stats.log

like image 127
Spencer Avatar answered Sep 30 '22 12:09

Spencer