curl and popen2

Discussion in 'Python' started by lists04@gmail.com, Feb 2, 2005.

  1. Guest

    Hi,

    I have a problem with a curl request and running it under popen2.

    If I run this request from the command line:
    curl -i http://www.yahoo.com/test --stderr errfile
    (also tried redirecting stdderr to a file 2>, nothing) the file errfile
    is empty indicating no error with the request.

    However, when I do something similar in python:
    >>> cmd="curl -i http://www.yahoo.com/test"
    >>> output, input, err = popen2.popen3(cmd)
    >>> error = err.readlines()
    >>> error

    [' % Total % Received % Xferd Average Speed Time
    Curr.\n', ' Dload Upload Total
    Current Left Speed\n', '\r100 981 0 981 0 0 24525
    0 --:--:-- 0:00:00 --:--:-- 24525\r100 2484 0 2484 0 0
    62100 0 --:--:-- 0:00:00 --:--:-- 1467k\n']

    I looked in the man page for curl, it doesnt say that it writes some
    bandwidth statistics to stderr. Am I missing something or is this
    better directed to some other newsgroup?

    TIA

    Hari
     
    , Feb 2, 2005
    #1
    1. Advertising

  2. On Tue, 01 Feb 2005 17:48:53 -0800, lists04 wrote:

    > Hi,
    >
    > I have a problem with a curl request and running it under popen2.
    >
    > If I run this request from the command line:
    > curl -i http://www.yahoo.com/test --stderr errfile
    > (also tried redirecting stdderr to a file 2>, nothing) the file errfile
    > is empty indicating no error with the request.
    >
    > However, when I do something similar in python:
    >>>> cmd="curl -i http://www.yahoo.com/test"
    >>>> output, input, err = popen2.popen3(cmd)
    >>>> error = err.readlines()
    >>>> error

    > [' % Total % Received % Xferd Average Speed Time
    > Curr.\n', ' Dload Upload Total
    > Current Left Speed\n', '\r100 981 0 981 0 0 24525
    > 0 --:--:-- 0:00:00 --:--:-- 24525\r100 2484 0 2484 0 0
    > 62100 0 --:--:-- 0:00:00 --:--:-- 1467k\n']
    >
    > I looked in the man page for curl, it doesnt say that it writes some
    > bandwidth statistics to stderr. Am I missing something or is this
    > better directed to some other newsgroup?
    >


    Many of the more "sophisticated" command line applications use stderr to
    write things that are intended directly for the user's eyes. The idea is
    that it is often useful to have the file itself be written to stdout so
    that pipes can be used, but the user still needs to see what is going on.
    Try using "curl --silent -i http://www.yahoo.com/test". That should turn
    off all of the "user-friendly" updates to stderr.

    -Robey Holderith

    > TIA
    >
    > Hari
     
    Robey Holderith, Feb 2, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Swerdlow

    Python daemon and popen2

    Bob Swerdlow, Sep 3, 2004, in forum: Python
    Replies:
    1
    Views:
    335
    Thomas Guettler
    Sep 6, 2004
  2. Roman Yakovenko
    Replies:
    0
    Views:
    1,632
    Roman Yakovenko
    Sep 7, 2004
  3. Jeff Epler
    Replies:
    0
    Views:
    420
    Jeff Epler
    Sep 8, 2004
  4. Alessandro Bottoni
    Replies:
    0
    Views:
    503
    Alessandro Bottoni
    Aug 9, 2005
  5. Magnus Lycka

    Problem with select.poll and popen2

    Magnus Lycka, Aug 30, 2005, in forum: Python
    Replies:
    1
    Views:
    2,585
    Magnus Lycka
    Aug 30, 2005
Loading...

Share This Page