note 120737 deleted from ref.exec by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 20:58:20 +0000 |
| Subject: | note 120737 deleted from ref.exec by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217996@lists.php.net to get a copy of this message | ||
Note Submitter: HappyDog, kennel17.co.uk
----
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.]