|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-21 12:54 UTC] not-implemented at mark-plomer dot de
Description:
------------
If i have a complicated commandline with quotes and spaces in it, and pass it to exec(), system(), ..., then i get under Windows "path or filename not found" despite the filenames are correct.
The Problem is the following:
PHP starts a command over the command-interpreter by prefixing the commandline with "cmd.exe /c ".
Test in DOS-Box:
If I enter the command in a "DOS-Box", the result is ok, but if I prefix it with "cmd.exe /c ", then i get the same failure as in PHP.
If you read the "manpage" ("cmd.exe /?"), there is a hint, that "cmd.exe /c" has problems with quotes. And IMHO there is no way to escape theese quotes.
My solutions are:
- Someone finds a way to escape quotes for cmd.exe
- A new Parameter for system()/exec()/...
- ... or better: A php.ini-setting, ... which controls, if the command is executed over the shell, or executed directly.
Reproduce code:
---------------
system('"D:\Program Files\fop\fop.bat" "path with blanks/to/bla.fo" "output path/bla.pdf"');
Expected result:
----------------
Successful execution.
Actual result:
--------------
cmd.exe says: "path/file not found"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 11:00:02 2025 UTC |
I don't see a need to add an option. Regarding the original report, the solution would be to enclose the command in another pair of double-quotes, e.g. system('""D:\Program Files\fop\fop.bat" "path with blanks/to/bla.fo" "output path/bla.pdf""'); As of PHP 5.3.11, this additional pair of double-quotes is inserted by PHP, so the original test script should work as is. See also <https://github.com/php/php-src/pull/5102>.