Subprocess issues with platform independence
Postby ajamin on Wed Oct 08, 2008 10:46 am
I am writing a python script that will act as a wrapper for another
program. The python script will provide the inputs for this program
and will verify that the output is correct. The application runs on
multiple OS's including windows and *nix.
This is the code:
Code: Select all
Help with Code Tags
python Syntax (Toggle Plain Text)
1.
import os, sys, string, time, subprocess
2.
command = "OK\r\n"
3.
p = subprocess.Pope n( ("C:\setup-winnt.exe", "-console"),
4.
stdin = subprocess.PIPE ,
5.
stdout = subprocess.PIPE ,
6.
stderr = subprocess.PIPE )
7.
stdout_text, stderr_text = p.communicate(c ommand)
8.
sys.stdout.writ elines(stdout_t ext.rstrip())
import os, sys, string, time, subprocess command = "OK\r\n" p =
subprocess.Pope n( ("C:\setup-winnt.exe", "-console"), stdin =
subprocess.PIPE , stdout = subprocess.PIPE , stderr = subprocess.PIPE )
stdout_text, stderr_text = p.communicate(c ommand)
sys.stdout.writ elines(stdout_t ext.rstrip())
On the *nix version, the application to open ("C:\setup-winnt.exe")
and the command ("OK\r\n") are different. The plan is to refactor this
as the code develops.
The above code works fine on *nix. On these OS's the application
launches in the same console that the command is issued from. On
windows the behavior is different. When the command is executed an
initialization window opens. When this window closes, a command window
is opened. It is this command window that I wish to send commands to.
I believe this command window may be started as a child process of the
application. However it is opened, it does not accept input from the
stdin of the process.
Any suggestions? 0 981 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Uri Nix |
last post by:
Hi all,
I've been trying to use (Python 2.4 on WinXP) the subprocess module to
execute a shell command (nmake in this case), and pass its output to a
higher level.
Using the following snippet:
p =
subprocess.Popen(nmake,stderr=subprocess.PIPE,stdout=subprocess.PIPE, \
universal_newlines=True, bufsize=1)
|
by: Stewart Midwinter |
last post by:
this has me puzzled; I've created a small test app to show the problem
I'm having.
I want to use subprocess to execute system commands from inside a
Tkinter app running under Cygwin.
When I open a python interpreter and run my subprocess command, all is
well. But when I run the same command from inside a Tkinter app, I'm
getting errors.
|
by: Ivan Vinogradov |
last post by:
Dear All,
I would greatly appreciate a nudge in the right direction concerning
the use of cwd argument in the call function from subprocess module.
The setup is as follows:
driver.py <- python script
core/ <- directory
main <- fortran executable in the core directory
|
by: Grant Edwards |
last post by:
I'm trying to use the py-gnuplot module on windows, and have
been unable to get it to work reliably under Win2K and WinXP.
By default, it uses popen(gnuplotcmd,'w'), but in some
situations that consistently gets an "invalid operand" IOError
when write() is called on the pipe.
So I switched to subprocess. It works fine when executed...
|
by: JD |
last post by:
Hi,
I want send my jobs over a whole bunch of machines (using ssh). The
jobs will need to be run in the following pattern:
(Machine A) (Machine B) (Machine C)
Job A1 Job B1 Job C1
Job A2 Job B2 etc
| |
by: Harishankar |
last post by:
Hi,
Sorry to start off on a negative note in the list, but I feel that the Python
subprocess module is sorely deficient because it lacks a mechanism to:
1. Create non-blocking pipes which can be read in a separate thread (I am
currently writing a mencoder GUI in Tkinter and need a full fledged process
handler to control the command line...
|
by: Michel Lespinasse |
last post by:
On Thu, Aug 28, 2008 at 10:37:48AM +0100, Tim Golden wrote:
The root cause is different (subprocess has separate implementations
for windows and posix), but the issues are similar. In the posix case,
I only observed the issue when you using subprocess.PIPE
The attached patch against subprocess.py (as shipped on debian etch,
based on...
|
by: Jeremy Banks |
last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the
Popen class in the subprocess module. Popen sounds like the a suitable
name for a function that created a subprocess, but the object itself is
a subprocess, not a "popen". It seems that it would be more accurate to
just name the class Subprocess, can anyone explain why this...
|
by: Chuckk Hubbard |
last post by:
If I run 'python -i subprocessclient.py' I expect to see the nice
level of it go up 2, and the nice level of the subprocess go up 1.
But all I see is the nice level of the client change. What am I doing
wrong?
subprocessserver.py:
----------------------------
#!/usr/bin/python2.5
import os
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |