process cannot access the file because it is being used by other process

Chris Rebert clp2 at rebertia.com
Mon Jun 21 15:43:26 EDT 2010


On Mon, Jun 21, 2010 at 6:44 AM, Felipe Vinturini
<felipe.vinturini at gmail.com> wrote:
<snip>
> Your problem seems to be with stdout redirect to the same file:
> ">YourOutput1.txt". Windows is not like Unix like systems!
> You can try, instead of redirecting to the same file, redirect each to a
> separate file and use the following form:
> <code>
>        proc = subprocess.Popen(r'C:\WINDOWS\system32\cmd.exe /C
> "D:\372\pythonweb\mongoose-2.8.exe -root D:\New1\ 1>YourOutput.txt 2>&1"')
> </code>

I believe the cmd.exe ugliness can also be avoided altogether:
proc = subprocess.Popen([r'D:\372\pythonweb\mongoose-2.8.exe',
'-root', 'D:\New1\'], stderr=subprocess.STDOUT,
stdout=file("YourOutput.txt", 'w'))

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list