473,657 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:
cmd="curl -i http://www.yahoo.com/test"
output, input, err = popen2.popen3(c md)
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

Jul 18 '05 #1
1 1862
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(c md)
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 "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
TIA

Hari

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7131
by: Guy | last post by:
Hi I was given an exstremly useful answer to a problem that I had in windows. I'm relativly new with python, but find it exstremly useful. I'm creating a script to run test files and record output, the script already works on win32 and I've made a telnet procedure which works quite well when you want to do the testing on one of the many unix boxes (but its very slow). What I want to do now is run the script on a unix system, and later...
1
1708
by: A. Lloyd Flanagan | last post by:
OK, I've got a weird one I haven't been able to figure out yet. Admittedly I haven't had time to dig into the library source, but this behavior certainly doesn't seem right. Here's a test case: """Test program to demonstrate problem with popen2 module.""" import popen2 def main (argv): mycmd = 'python2.3 -c "for i in range(100000):\n print i"' p = popen2.Popen3(mycmd)
1
3101
by: | last post by:
This could possibly be a bug, but I don't understand it fully so I'm posting here first. Searching the list told me other people are having this problem too. I have created a class which inherits popen2.Popen3. The problem is that popen2.Popen3 does not define a __del__ method to handle proper closing of the pipes or destruction of the process. So I created one in my class:
4
1658
by: P | last post by:
I've written a couple of apps that required running a command and grabbing the output, and I've found the existing interfaces problematic for this. I think the proliferation of functions and classes in the popen2 module illustrates the problem (popen2.{popen2,popen3,popen4,Popen3,Popen4}) Now if I want to read both stdout and stderr seperately then it's awkward to say the least to implement that without deadlocking using
1
2656
by: Vivien Mallet | last post by:
Hello, I use popen2.Popen4 and I experienced problems with it. Let me show you with an example. The following script is called "lines" (it prints lines of 'X'): --------------------- #!/usr/bin/env python import sys
1
2570
by: Magnus Lycka | last post by:
I'm trying to read standard out in a process started with popen2 in a non-blocking way. (Other good ways of doing this than the one I tried are appreciated.) I've tried to dumb down my code to see what happens, and socket.poll seems to behave very strangely. I've tried to use the .poll method for the poll object with and without a timeout, but in either case, the output randomly switches between on of the versions below. It runs fast,...
9
1829
by: Martin P. Hellwig | last post by:
Hi all, I was doing some popen2 tests so that I'm more comfortable using it. I wrote a little python script to help me test that (testia.py): --------------------------------- someline = raw_input("something:") if someline == 'test': print("yup")
3
3100
by: mikem76 | last post by:
How do I automatically redirect stdout and stderr when using os.popen2 to start a long running process. If the process prints a lot of stuff to stdout it will eventually stop because it runs out of buffer space. Once I start reading the stdout file returned by os.popen2 then the process resumes. I know that I could just specify > /dev/null when starting the process but I'd like to know if there is a way to start a process using os.popen2...
1
1794
by: diego | last post by:
I'm trying to understand how popen2 works. Found in this group, that popen2.popen2 can cause trouble so i chose win32pipe.popen2. have a look a the listing of 2 files: ekmain.py: ************** import win32pipe (stdin1, stdout1) = win32pipe.popen2("test1.py") stdin1.write("1\n")
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.