Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > curl and popen2

Reply
Thread Tools

curl and popen2

 
 
lists04@gmail.com
Guest
Posts: n/a
 
      02-02-2005
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

 
Reply With Quote
 
 
 
 
Robey Holderith
Guest
Posts: n/a
 
      02-02-2005
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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with select.poll and popen2 Magnus Lycka Python 1 08-30-2005 03:56 PM
Examples and tutorials about popen2/3, smtplib/multipart and icq/jabber? Alessandro Bottoni Python 0 08-09-2005 05:01 PM
Re: os.popen4 and popen2.popen4 undocumented behavior Jeff Epler Python 0 09-08-2004 02:22 PM
os.popen4 and popen2.popen4 undocumented behavior Roman Yakovenko Python 0 09-07-2004 04:42 AM
Python daemon and popen2 Bob Swerdlow Python 1 09-06-2004 02:42 PM



Advertisments