On Windows with PHP versions prior to 5.3.0, commands passed to exec() (and its siblings) actually execute the command: 'cmd /c $cmd'. If $cmd contains spaces, it needs to be wrapped in quotation marks.
For example, I'm trying to run this:
io_exec('pdftotext "C:\input\file name.pdf" "C:\output\file name.pdf"');
but this ends up as
cmd /c pdftotext "C:\input\file name.pdf" "C:\output\file name.pdf"
when it needs to be
cmd /c "pdftotext "C:\input\file name.pdf" "C:\output\file name.pdf""
I'm currently using the following as a workaround to this issue, and I'm wondering if it might be considered for addition into io_exec(), so that it doesn't have to be repeated everywhere.
if( PHP_OS=='WINNT' && version_compare(PHP_VERSION, '5.3.0', '<') ) {
$cmd = '"'.$cmd.'"';
}
See these links for some more info about this problem:
*
http://stackoverflow.com/questions/4255162/exec-quoting-full-command-in-windows
*
http://www.php.net/manual/en/ref.exec.php#80721
Thanks,
Sam.