Getting Windows exec to work better.

php.internals

Richard Quadling

19 years ago
Hi. http://bugs.php.net/bug.php?id=25361 I supplied a patch to fix this bug. The issue is NOT a PHP bug, but a "that's how it is on windows" issue. On *nix, if you want to exec a program via PHP whose program name or parameters contain spaces, do you need to use a pair of double quotes around the name/parameter? If so, are there any issues if you have many sets of double quotes? If not, then this is a difference between *nix and windows for the operation of PHP. With the patch it should deal with this, allowing PHP userland code to operate in the same way on both platforms. If someone could take a look, I'd be grateful. Richard.
-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"

Nuno Lopes

19 years ago
Things are not that simple. I would advise you to read a more than one year thread about the very same subject: http://marc.info/?l=php-dev&m=113919491216978 Nuno ----- Original Message ----- From: "Richard Quadling" <rquadling@googlemail.com> To: "PHP Developers Mailing List" <internals@lists.php.net> Sent: Thursday, August 09, 2007 8:43 AM Subject: [PHP-DEV] Getting Windows exec to work better.

Richard Quadling

19 years ago
On 09/08/07, Nuno Lopes <nlopess@php.net> wrote:
> Things are not that simple. > I would advise you to read a more than one year thread about the very same > subject: http://marc.info/?l=php-dev&m=113919491216978 > > Nuno > > > ----- Original Message ----- > From: "Richard Quadling" <rquadling@googlemail.com> > To: "PHP Developers Mailing List" <internals@lists.php.net> > Sent: Thursday, August 09, 2007 8:43 AM > Subject: [PHP-DEV] Getting Windows exec to work better. > > > > Hi. > > > > http://bugs.php.net/bug.php?id=25361 > > > > I supplied a patch to fix this bug. > > > > The issue is NOT a PHP bug, but a "that's how it is on windows" issue. > > > > On *nix, if you want to exec a program via PHP whose program name or > > parameters contain spaces, do you need to use a pair of double quotes > > around the name/parameter? If so, are there any issues if you have > > many sets of double quotes? If not, then this is a difference between > > *nix and windows for the operation of PHP. > > > > With the patch it should deal with this, allowing PHP userland code to > > operate in the same way on both platforms. > > > > If someone could take a look, I'd be grateful.
Ok. Thanks for the link. I have read similar notes but no response as to why the patches supplied have NOT been committed. IIRC ... [2007-08-03 10:03:00] <Pierre> we don't care about 9x [2007-08-03 10:03:27] <Pierre> RichardQ, did you test it on recent windows too? I wonder if we can have more tests about this problem (if possible) Is PHP on 9x "supported"? I'm using XP, and from the command line, calling ... %comspec% /s /c ""program name here with spaces" "parameter here with spaces"" works fine. e.g. %comspec% /c ""C:\Program Files\Internet Explorer\iexplore.exe" "http://www.google.com/search?q=php with spaces"" Loads internet explorer with the appropriate google page. In PHP ... <?php exec('""C:\Program Files\Internet Explorer\iexplore.exe" "http://www.google.com/search?q=php with spaces""'); ?> as does ... cd "Program Files\Internet Explorer" %comspec% /s /c "iexplore.exe "http://www.google.com/search?q=php with spaces"" But having to wrap your entire command line with quotes is not consistent with *nix platforms. And for the sake of a few additional characters in the exec method for windows (with the split for NT+ vs 9x), then this would save a lot of headache and once again, make PHP windows compatible.
-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"

Tim Starling

19 years ago
Richard Quadling wrote:
>On 09/08/07, Nuno Lopes <nlopess@php.net> wrote: > > >>Things are not that simple. >>I would advise you to read a more than one year thread about the very same >>subject: http://marc.info/?l=php-dev&m=113919491216978 >> >> >> >> >Ok. Thanks for the link. I have read similar notes but no response as >to why the patches supplied have NOT been committed. > >
My patch wasn't committed because it didn't supply a backwards compatibility option and nobody provided one. It should be a fairly simple task. -- Tim Starling

Richard Quadling

19 years ago
On 09/08/07, Tim Starling <tstarling@wikimedia.org> wrote:
> Richard Quadling wrote: > > >On 09/08/07, Nuno Lopes <nlopess@php.net> wrote: > > > > > >>Things are not that simple. > >>I would advise you to read a more than one year thread about the very same > >>subject: http://marc.info/?l=php-dev&m=113919491216978 > >> > >> > >> > >> > >Ok. Thanks for the link. I have read similar notes but no response as > >to why the patches supplied have NOT been committed. > > > > > My patch wasn't committed because it didn't supply a backwards > compatibility option and nobody provided one. It should be a fairly > simple task. > > -- Tim Starling
Being slightly sarcy, the current mechanism DOESN'T work unless you know about wrapping the entire string in double quotes. So, we are going from a broken mechanism to a working mechanism. I don't see why BC cannot be broken for this!?
-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"