473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Subprocess problem on multiple OS's

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.Popen( ("C:\setup-winnt.exe", "-console"),
4.
stdin = subprocess.PIPE,
5.
stdout = subprocess.PIPE,
6.
stderr = subprocess.PIPE)
7.
stdout_text, stderr_text = p.communicate(command)
8.
sys.stdout.writelines(stdout_text.rstrip())

import os, sys, string, time, subprocess command = "OK\r\n" p =
subprocess.Popen( ("C:\setup-winnt.exe", "-console"), stdin =
subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
stdout_text, stderr_text = p.communicate(command)
sys.stdout.writelines(stdout_text.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?
Oct 10 '08 #1
0 970

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

Similar topics

6
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...
2
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...
3
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 <-...
5
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...
10
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 ...
23
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...
0
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...
25
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...
2
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.