473,804 Members | 3,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

popen4

Hi all. I'm trying to execute system commands and capture the output by
using popen4:

stdout example:
exec_cmd = popen2.popen4(" echo hello!")
output = exec_cmd[0].read() hello

stderr example:exec_cmd = popen2.popen4(" echobv hello!")
output = exec_cmd[0].read()

Unrecognized command

The problem occurs when I try to execute interactive commands like ftp,
python intepreter etc...
In this case the program crashes without even giving an error.
Suggestions?

Regards
Oct 16 '05 #1
4 2585
>>>>> "billie" <ml***@fastwebn et.it> (b) wrote:
b> Hi all. I'm trying to execute system commands and capture the output by
b> using popen4: b> stdout example:
> exec_cmd = popen2.popen4(" echo hello!")
> output = exec_cmd[0].read()b> hello b> stderr example:> exec_cmd = popen2.popen4(" echobv hello!")
> output = exec_cmd[0].read()
b> Unrecognized command

b> The problem occurs when I try to execute interactive commands like ftp,
b> python intepreter etc...
b> In this case the program crashes without even giving an error.
Crashes?
b> Suggestions?


I think you need something like pyexpect for this.
--
Piet van Oostrum <pi**@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C 4]
Private email: pi**@vanoostrum .org
Oct 17 '05 #2

Piet van Oostrum wrote:
I think you need something like pyexpect for this.


PyExpect seems to be no more mantained.
Oct 18 '05 #3
>>>>> "billie" == billie <ml***@fastwebn et.it> writes:
Piet van Oostrum wrote:
I think you need something like pyexpect for this.
PyExpect seems to be no more mantained.


Try pexpect instead. http://pexpect.sourceforce.net/

Ganesan

--
Ganesan Rajagopal (rganesan at debian.org) | GPG Key: 1024D/5D8C12EA
Web: http://employees.org/~rganesan | http://rganesan.blogspot.com

Oct 18 '05 #4
Ganesan Rajagopal wrote:
Try pexpect instead. http://pexpect.sourceforce.net/

^

That's a content-free ad site. You probably mean sourceforGe.

Ralf
Oct 19 '05 #5

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

Similar topics

0
1090
by: Patrick L. Nolan | last post by:
We have a python+Tkinter program that works properly on Linux, but when moved to Windows (XP) it behaves in a strange way. There's a section like this: (child_out, child_in) = popen2.popen4(cmd) line = child_out.readline() while line: do_something_with(line) line = child_out.readline()
2
1808
by: Patrick L. Nolan | last post by:
We have an application that works on Linux. It has to be ported to Windows XP, and there's one bug that's driving me crazy. There's a number-crunching program written in C++. It is invoked by a Tkinter python script. The script uses the threading module to separate out the heavy processing. The worker thread uses popen4 to run the C++ program and capture its standard output. This output is sent to the master thread through a queue...
1
2663
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
0
1173
by: Jim | last post by:
Hi, I'm using popen2.Popen4 and I'm curious what exceptions it could raise for example p = popen2.POpen4( 'command string' ) i'm assuming would only raise OSError exceptions if something went wrong internally with popen. and also, for read operations like: p.fromchild.read()
0
1350
by: Roman Yakovenko | last post by:
Hi. May be I found bug may be not, but I definitely could not find answer in documentation and GOOGLE. Environment: Windows XP and Python 2.3 Description: I have program that returns negative numbers as errors int main() { return -1; }
0
1146
by: rinkworks | last post by:
I'm having trouble with Popen4 locking up on me. It appears to be unrelated to the actual command I'm running, because I made the command just "cat" (I'm on UNIX) to echo whatever input I sent it, and it's still locking. The trick is, it works for small amounts of data. After roughly 1.5K of input, it locks up and will not write any more data to the pipe. I assume a buffer got full somewhere, and it's blocking the write call. ...
2
1565
by: Grant Edwards | last post by:
I'm having problems calling the Popen4 object wait() method from a thread. The folloing program produces an error on some machines (but seems to work on others) ------------------------------8<------------------------------ import time import threading import popen2 def monitorThread():
0
1185
by: micklee74 | last post by:
hi i have to execute some SQL statements against a database using a SQL client i want to use the os.popen4 module can someone correct the way i use os.popen4? thanks fin = "select * from some_table" #sql statement client = "osql server user password" #sql client syntax fin, fout = os.popen4(client)
1
1107
by: julian | last post by:
Hi all, I know it's a kind of bizarre question but here I go: I want to execute an script using popen4. This script executes a command in turn using popen4 too. The first one throws a 256 exit code. Any suggestions? Thanks J.
0
9585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6856
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
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.