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

Home Posts Topics Members FAQ

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

subprocess.Popen spawning cmd shells

Hi,
I'm currently writing a python program that relies on a CLI
program. What I'm currently doing is using subprocess.Popen on Python
2.5.1. Here's the line that I'm currently running:

child = subprocess.Popen(["c:\app.exe", node, "-w",
str(tmpTime * 1000), '-n', str(1), '-l'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

The problem is that although the above works, a CMD shell is spawned
and becomes visible for each time I run the above. I thought that by
redircting stdin, stdout and stderr, no CMD shell should pop-up. Is
something wrong in the way I'm using subprocess? Thanks for your help.
Jan 9 '08 #1
1 3776
On Jan 9, 5:17*pm, Mrown <mathewbr...@fastmail.fmwrote:
Hi,
* I'm currently writing a python program that relies on a CLI
program. *What I'm currently doing is using subprocess.Popen on Python
2.5.1. *Here's the line that I'm currently running:

* * * * * * child = subprocess.Popen(["c:\app.exe", node, "-w",
str(tmpTime * 1000), '-n', str(1), '-l'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

The problem is that although the above works, a CMD shell is spawned
and becomes visible for each time I run the above. *I thought that by
redircting stdin, stdout and stderr, no CMD shell should pop-up. *Is
something wrong in the way I'm using subprocess? *Thanks for your help.
To anyone interested, I found the solution by using the
CREATE_NO_WINDOW creation flag. So this is what the code now looks
like (and it doesn't spawn any shells):

CREATE_NO_WINDOW = 0x8000000
child = subprocess.Popen(["c:\app.exe", node, "-w",
str(tmpTime * 1000), '-n', str(1), '-l'], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags =
CREATE_NO_WINDOW)
Jan 9 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Michele Simionato | last post: by
2 posts views Thread by micklee74 | last post: by
12 posts views Thread by Eric_Dexter | last post: by
9 posts views Thread by Phoe6 | last post: by
10 posts views Thread by JD | last post: by
12 posts views Thread by bhunter | last post: by
25 posts views Thread by Jeremy Banks | last post: by
reply views Thread by rosydwin | 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.