Vá: Re: Python - Execute more programs

So I trying with it:

*test.py

import os

pypath='c:\Python\python.exe'
filename='c:/test2.py'

params='-a:'
args = [pypath, filename] + params.split()
print "1. before"
os.spawnv(os.P_NOWAIT,pypath,args)
print "1. after"
params='-b:'
args = [pypath, filename] + params.split()
print "2. before"
os.spawnv(os.P_NOWAIT,pypath,args)
print "2. after"

*test2.py

import sys
s=sys.argv[1]
print s
print "running"
for i in range(1,100): print s+str(i)

But if I run the test.py, the two test2 intance is working into one stdout:
the printing is merging...
It is more good before I trying, but not enough. I want to start new program in new cmd/dos console.

Thx:
KK

robin@alldunn.com 30.06.03 19:18 >>>

You're executing python.exe but giving it a single parameter that is the
.py file and its arg, so Python will be looking for a file named
"c:/homedev/neurolotto/bin/v1.0/Neurolotto.py -W1 -S1". Instead you
should pass each arg separately. Plus, IIRC you need to pass the
commandpath again in the first arg (so it can be argv[0] in the executed
program.) Try this:

  args = [pypath, filename] + params.split()
  os.spawnv(os.P_NOWAIT, pypath args)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Krisztian Kepes wrote:

But if I run the test.py, the two test2 intance is working into one
stdout: the printing is merging...
It is more good before I trying, but not enough. I want to start new
program in new cmd/dos console.

Do you really need a new console window for each, or do you just want to capture the stdout of the child programs? If the former then you can do it with wxExecute using the wxEXEC_ASYNC|wxEXEC_NOHIDE flags. If the latter then you can also do it with wxExecute (see the demo,) but also one of the os.popen* functions will probably suite you.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!