From: mplomer at gmx dot de Operating system: WinXP PHP version: 5CVS-2005-10-21 (snap) PHP Bug Type: Program Execution Bug description: exec(): Problem with quotes in commandline
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" -- Edit bug report at http://bugs.php.net/?id=34945&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34945&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34945&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34945&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34945&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34945&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34945&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34945&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34945&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34945&r=support Expected behavior: http://bugs.php.net/fix.php?id=34945&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34945&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34945&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34945&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34945&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34945&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34945&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34945&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34945&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34945&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34945&r=mysqlcfg