471,873 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 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)

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)

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)
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 892

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Uri Nix | last post: by
2 posts views Thread by Stewart Midwinter | last post: by
3 posts views Thread by Ivan Vinogradov | last post: by
5 posts views Thread by Grant Edwards | last post: by
10 posts views Thread by JD | last post: by
reply views Thread by Michel Lespinasse | last post: by
25 posts views Thread by Jeremy Banks | last post: by
2 posts views Thread by Chuckk Hubbard | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

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.