note 120737 added to ref.exec

From: Date: Sat, 04 Mar 2017 11:22:12 +0000
Subject: note 120737 added to ref.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-208869@lists.php.net to get a copy of this message
In response to lancelot--du-lac at hotmail dot fr, who pointed out some issues with commands containing multiple quoted strings when calling shell functions on Windows: I have also recently encountered this issue when trying to run my code on PHP 5.2. The code runs fine on PHP 5.3 and above so I guess the problem has been fixed (though I couldn't find a mention of it in the PHP release notes), but on 5.2 it behaves as described in that post. Although the original post says there was no output, this isn't quite right. The reason there was no output is because the error is being sent to stderr, which wasn't being captured. Adding " 2>&1" to the end of the command means you also see this output. This ends up being quite illuminating; I was getting was something like this: 'C:\Program' is not recognized as an internal or external command, operable program or batch file. Clearly, having two quoted strings in the command confuses the shell commands; the result is the same as if you ran the command without any quotes. I haven't found a workaround for anyone who still needs to support 5.2, but as I say, it doesn't seem to be an issue on later PHP versions. [Note: I was also testing on Windows XP (SP3), so I am not sure if this was a general Windows issue or specific to XP.] ---- Server IP: 72.52.91.14 Probable Submitter: 212.69.47.82 ---- Manual Page -- http://php.net/manual/en/ref.exec.php Edit -- https://master.php.net/note/edit/120737 Del: integrated -- https://master.php.net/note/delete/120737/integrated Del: useless -- https://master.php.net/note/delete/120737/useless Del: bad code -- https://master.php.net/note/delete/120737/bad+code Del: spam -- https://master.php.net/note/delete/120737/spam Del: non-english -- https://master.php.net/note/delete/120737/non-english Del: in docs -- https://master.php.net/note/delete/120737/in+docs Del: other reasons-- https://master.php.net/note/delete/120737 Reject -- https://master.php.net/note/reject/120737 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#208869) next »