curl and popen2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lists04@gmail.com

    #1

    curl and popen2

    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:[color=blue][color=green][color=darkred]
    >>> cmd="curl -i http://www.yahoo.com/test"
    >>> output, input, err = popen2.popen3(c md)
    >>> error = err.readlines()
    >>> error[/color][/color][/color]
    [' % 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

  • Robey Holderith

    #2
    Re: curl and popen2

    On Tue, 01 Feb 2005 17:48:53 -0800, lists04 wrote:
    [color=blue]
    > 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:[color=green][color=darkred]
    >>>> cmd="curl -i http://www.yahoo.com/test"
    >>>> output, input, err = popen2.popen3(c md)
    >>>> error = err.readlines()
    >>>> error[/color][/color]
    > [' % 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?
    >[/color]

    Many of the more "sophistica ted" 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
    [color=blue]
    > TIA
    >
    > Hari[/color]


    Comment

    Working...