How do I enable the curl progress bar in cygwin?

23
2014-04
  • obesechicken13

    When you curl a file, you get this progress bar whether you're uploading or downloading a file.

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    100   401  100   401    0     0   5141      0 --:--:-- --:--:-- --:--:--  8531
    

    I'm trying to curl a file on my personal laptop using cygwin and no progress bar is showing up. I checked the manual and by all accounts a progress bar should show up but it doesn't. I had to install the curl package for cygwin so maybe I edited the settings. All other stdout from normal shell commands and from other languages shows up. curl can write http gets to stdout too.

    curl -O http://blah.blah.com/blah/blah.png
    

    The file gets there fine and I can open and view it. There's just no meter.

    It's just a minor inconvenience and was wondering if anyone knew how to deal with it.

    I got curl sometime this summer so I don't think my version is very old. Curl does show the progress bar works fine when I run it from a windows command prompt.

    TL:DR, how do I get the progress bar to show up?

  • Answers
  • me_and

    Curl will only display a progress meter for a substantial download. If I download the StackOverflow About page, for example, it just downloads with no progress meter. If, however, I download an Ubuntu ISO, I do see that progress meter:

    $ curl -O http://stackoverflow.com/about
    
    $ curl -O 'http://mirror.ox.ac.uk/sites/releases.ubuntu.com/releases//precise/ubuntu-12.04.1-desktop-i386.iso'
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      6  695M    6 42.6M    0     0  8738k      0  0:01:21  0:00:05  0:01:16 8858k
    

  • Related Question

    bash - cURL: how to suppress strange output when redirecting?
  • Ian Mackinnon

    I'm trying to print just the verbose sections of a cURL request (which are sent to stderr) from the bash shell.

    But when I redirect stdout like this:

    curl -v http://somehost/somepage > /dev/null
    

    Some sort of results table appears in the middle of the output to stderr:

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    

    Followed by this near the end:

    { [data not shown]
    118   592    0   592    0     0  15714      0 --:--:-- --:--:-- --:--:-- 25739
    

    Which makes the response headers less readable.

    I don't see this text when not redirecting.


    Another way to see the effects:

    Table doesn't appear:

    curl -v http://somehost/somepage 2>&1
    

    Table appears:

    curl -v http://somehost/somepage 2>&1 | cat
    

    1) How come this shows up only with certain types of redirects?

    2) What's the neatest way to suppress it?

    Thank you


  • Related Answers
  • Dennis Williamson

    Try this:

    curl -vs -o /dev/null http://somehost/somepage 2>&1
    

    That will suppress the progress meter, send stdout to /dev/null and redirect stderr (the -v output) to stdout.

  • Ian Mackinnon

    With reference to question 1 (how cURL knows to only display the table when output is redirected), I didn't realise a program could tell its outputs were being directed, but it seems on POSIX systems there is a function isatty which reports whether or not a file descriptor refers to a terminal.

  • user1065951

    To put real error messages somwhere, you should write strerr into a log file. Something like that:

    curl  "http://domain.name/process" --stderr /var/log/curl_err.log > /dev/null
    
  • mhoydis
    curl --fail --silent --show-error http://www.example.com/ > /dev/null
    

    This will suppress the status dialog, but will otherwise output errors to STDERR normally.

    user@host:~# curl http://www.yahoo.com > /dev/null
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  254k    0  254k    0     0   403k      0 --:--:-- --:--:-- --:--:--  424k
    

    The above outputs the status table when redirecting.

    user@host:~# curl --fail --silent --show-error http://www.yahoo.com > /dev/null
    

    The above suppresses the status stable when redirecting, but errors will still go to STDERR.

    user@host:~# curl --fail --silent --show-error http://www.errorexample.com > /dev/null
    curl: (6) Couldn't resolve host 'www.errorexample.com'
    

    The above is an example of an error to STDERR.

    user@host:~# curl -v --fail --silent --show-error http://www.errorexample.com > ~/output.txt 2>&1
    user@host:~# cat ~/output.txt 
    * getaddrinfo(3) failed for www.errorexample.com:80
    * Couldn't resolve host 'www.errorexample.com'
    * Closing connection #0
    curl: (6) Couldn't resolve host 'www.errorexample.com'
    

    Just add 2>&1 to the end to redirect STDERR to STDOUT (in this case, to a file).