Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old October 10th, 2008, 06:35 PM
Amanda Jamin
Guest
 
Posts: n/a
Default 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?
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles