cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Redirecting the stats

From: Ralph Mitchell <rmitchell_at_eds.com>
Date: Thu, 28 Nov 2002 00:27:23 -0600

The stats come out on stderr, not stdout, so you'd need to do:

    curl -n $Source/access_log -o $Dest/access_log 2>> $Report

The problem with that approach is that the stats aren't just a simple line, as you'll see if you download a large file. The row of numbers is redrawn by issuing carriage-returns and rewriting it with the current figures, so your file will contain.

Check out the -w/--write-out option. You can turn off the progress meter and get whichever download stats you want in whatever order you want:

    curl -s -S -n $Source/access_log -o $Dest/access_log \
        -w "%{time_total},%{size_download},%{speed_download}\n" >> $Report

for example, to get the total time for the whole operation, the total bytes downloaded, and the verage speed of the download in a comma separated format.

Ralph Mitchell

Doug McNutt wrote:

> It's short so here's the whole thing:
>
> #!/bin/tcsh
> # Downloads log files from ISP.
> set Dest = $HOME/logs
> set Source = ftp://macnauchtan.com/logs
> set Report = $HOME/logs/shel_log
> date >> $Report
> curl -n $Source/access_log -o $Dest/access_log >> $Report
> echo "access_log, zero is OK "$? >> $Report
> curl -n $Source/error_log -o $Dest/error_log >> $Report
> echo "error_log, zero is OK "$? >> $Report
> exit
>
> The problem is that I don't see the stats in my Report file. The date and echos come out just as I expect. The list archives seem to say that redirecting with the -o option does not affect the stats and they do not show up at the end of the actual downloads. I have tried piping stdout to a subsequent echo but that doesn't work either. If I run the script from a terminal the stats are printed there. I have also tried redirecting stderr with no luck.
>
> I suspect it's simple but I'm baffled. Perhaps it's a MacOS neXt / Darwin / Jaguar problem.

-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
Received on 2002-11-28