Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > subprocess.Popen spawning cmd shells

Reply
Thread Tools

subprocess.Popen spawning cmd shells

 
 
Mrown
Guest
Posts: n/a
 
      01-09-2008
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.
 
Reply With Quote
 
 
 
 
Mrown
Guest
Posts: n/a
 
      01-09-2008
On Jan 9, 5:17*pm, Mrown <mathewbr...@fastmail.fm> wrote:
> 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)
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Spawning Cmd Window via Subprocess D Python 3 10-18-2009 09:07 PM
Re: Error spawning c:\windows\system32\cmd.exe jason.cipriani@gmail.com C++ 0 01-05-2009 10:26 AM
[exec cmd for cmd in cmds] =?ISO-8859-1?Q?Sch=FCle_Daniel?= Python 3 03-08-2006 03:21 PM
Interpreter-like help in cmd.Cmd Sarir Khamsi Python 4 06-26-2005 06:57 PM
read input for cmd.Cmd from file Achim Domma (Procoders) Python 2 06-03-2005 08:32 AM



Advertisments