Doc #78699 [Ver->Csd]: shell_exec on windows runs in text mode, this should be noted in the docs.

From: Date: Sun, 20 Oct 2019 10:37:32 +0000
Subject: Doc #78699 [Ver->Csd]: shell_exec on windows runs in text mode, this should be noted in the docs.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17027@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78699&edit=1 ID: 78699 Updated by: cmb@php.net Reported by: phpstuff at cresstone dot com Summary: shell_exec on windows runs in text mode, this should be noted in the docs. -Status: Verified +Status: Closed Type: Documentation Problem Package: Program Execution Operating System: Windows PHP Version: 7.3.10 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2019-10-20 10:37:01] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=348185 Log: Fix #78699: shell_exec on windows runs in text mode, this should be noted in the docs ------------------------------------------------------------------------ [2019-10-20 08:05:49] cmb@php.net Indeed, you're right. I think treating this as documentation issue is the right way. Thanks for reporting! ------------------------------------------------------------------------ [2019-10-20 07:39:44] phpstuff at cresstone dot com Disregard that last edit, stream_get_contents works fine and I've been at the keyboard too long. ------------------------------------------------------------------------ [2019-10-20 07:30:35] phpstuff at cresstone dot com Edit: The correct workaround code should be: $handle = popen('someCommand.exe', 'rb'); $binarySTDOUT=""; while (!feof($handle)) $binarySTDOUT.= fread($handle, 65536); pclose($handle); stream_get_contents() does not always produce the correct data for me. I'll investigate if that's a separate issue... ------------------------------------------------------------------------ [2019-10-20 05:35:07] phpstuff at cresstone dot com Description: ------------ --- From manual page: https://php.net/function.shell-exec --- On windows, shell_exe() & the backtick operator operate in text mode. When I was trying to get binary stdout from a command I encountered incorrect output, and the command I was running gave ‘broken pipe’ messages on its stderr. Any binary output that includes newlines seem to cause errors. The documentation doesn’t mention this, and took me a while to puzzle out what was happening. The work-around is to use popen() with the binary flag: $handle = popen('someCommand.exe', 'rb'); $binarySTDOUT = stream_get_contents($handle); pclose($handle); I wasn’t sure whether to file this as a language bug or just add a comment on the documentation, this report seemed like a good compromise... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78699&edit=1

« previous php.doc.bugs (#17027) next »