On 05/06/2015 06:11 PM, Stefan Zimmermann wrote:
Hi.

I don't like that subprocess.Popen(['command']) only works on Windows if there 
is a command.exe in %PATH%.

As a Windows user you would normally expect that also command.bat and command.cmd can be run that way.


and command.com.

If it's really unfortunate that you picked "command" for your sample program name. Since command.com was the shell in MSDOS, I was about to point you to COMSPEC to address your problem.

There's nothing Windows-specific about that behaviour. In Linux, there are bash commands that can only be run by using shell=True. Fortunately Popen didn't make the mistake of pretending it's a shell.

There is lots more to running a batch file than launching it. The whole syntax of the rest of the commandline differs when you're doing that.

There are simple workarounds like Popen(..., shell=True) but that is a heavy 
overhead for .exe files.

And the reason there's such an overhead is because you're requesting the services of the shell. If you don't need those services, use shell=False.


Currently I use pywin32 and call Popen([win32api.FindExecutable('command')[1]]) 
as a workaround. This has zero overhead.

It should be default for Popen to call FindExecutable internally.

Was this discussed before?
Is it worth a PEP?
Or at least an issue?

Cheers,
Stefan



--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to