|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-20 16:19 UTC] seld@php.net
Description: ------------ Running exec() seems to detect a non-zero (and specifically 1) return code/exit code for the process. No matter what process. It also affects the proc_open class of functions so there is not even a decent workaround as far as we know. Works on my machine but @johmue on github has the issue consistently. He tried with all latest 5.2, 5.3 and 5.4, even 5.5-alpha1. They all do the same. Yet on my machine 5.4.8 works fine. At first sight I have exactly the same OS and PHP build that he does, so this makes no sense to me. There must be something wrong in his environment but we are not able to figure out what causes it. Note that trying the same thing in the shell directly yields a correct result, so the issue seems to be in php, for example this works: C:\>dir [snip] C:\>echo %errorlevel% 0 You can find the full thread below, but I tried to sum it up above: https://github.com/composer/composer/issues/613 Test script: --------------- C:\>php -r "exec('dir', $out, $ret);var_dump($ret);" Expected result: ---------------- int(0) Actual result: -------------- Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch. int(1) ---- Interstingly, it does output the wrong return code, and also prints this warning saying that the syntax of the filename/command is wrong. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 11 13:00:01 2025 UTC |
Ok. I have a file called test.php: <?php exec('dir', $out, $ret); var_dump($ret); when I execute with PHP I get the following output: C:\Test>php -n test.php Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch. int(1) when I execute it directly in the shell I get: C:\Test>php -r "exec('dir', $out, $ret);var_dump($ret);" Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch. int(1) when I use the commands without PHP I get: C:\Test>dir Datenträger in Laufwerk C: ist ACER Volumeseriennummer: xxxxx Verzeichnis von C:\Test 27.11.2012 15:54 <DIR> . 27.11.2012 15:54 <DIR> .. 27.11.2012 15:56 47 test.php 1 Datei(en), 47 Bytes 2 Verzeichnis(se), 171.682.844.672 Bytes frei C:\Test>echo %errorlevel% 0 The commands are executed in every case. So I can add var_dump($out); to test.php and get: C:\Test>php -n test.php Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch. array(10) { [0]=> string(36) " Datenträger in Laufwerk C: ist ACER" [1]=> string(30) " Volumeseriennummer: xxxxx" [2]=> string(0) "" [3]=> string(24) " Verzeichnis von C:\Test" [4]=> string(0) "" [5]=> string(37) "27.11.2012 16:01 <DIR> ." [6]=> string(38) "27.11.2012 16:01 <DIR> .." [7]=> string(44) "27.11.2012 16:01 63 test.php" [8]=> string(48) " 1 Datei(en), 63 Bytes" [9]=> string(60) " 2 Verzeichnis(se), 171.683.024.896 Bytes frei" } int(1)