wiesson
wiesson

Reputation: 6822

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.

Upvotes: 6

Views: 7121

Answers (2)

Spencer
Spencer

Reputation: 329

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

Upvotes: 4

joncon
joncon

Reputation: 105

Only the stdout get redirected by the -o flag.

For the -o flag the man page states:

-o/--output <file>
          Write output to <file> instead of stdout...

If you want stderr, you need something like this:

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

Upvotes: 0

Related Questions