Edit report at http://bugs.php.net/bug.php?id=49139&edit=1

 ID:                 49139
 Updated by:         paj...@php.net
 Reported by:        david dot gausmann at measx dot com
 Summary:            proc_open requires double quotes
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Program Execution
 Operating System:   win32 only - Windows XP SP3
 PHP Version:        5.3.0
-Assigned To:        
+Assigned To:        pajoye
 Block user comment: N
 Private report:     N

 New Comment:

@xandrani at googlemail dot com



'"c:\program files\doxygen\bin\doxygen.exe" "C:\fred\doxyfile"'



works fine with proc_open.



For the initial comment and other:



<?php

echo PHP_EOL;

error_reporting(E_ALL|E_NOTICE);

$cmd = '"c:\\Program Files (x86)\\wcat\\wcutil.exe"';

$des = array

(

   0 => array('pipe', 'r'),

   1 => array('pipe', 'w'),

   2 => array('pipe', 'w')

);



$resource = proc_open($cmd, $des, $pipes, null, $_ENV);

var_dump(stream_get_contents($pipes[0]));

var_dump(stream_get_contents($pipes[1]));

var_dump(stream_get_contents($pipes[2]));



echo PHP_EOL;

echo "exec: " . PHP_EOL;

echo exec($cmd, $ret);

echo PHP_EOL;

print_r($ret);

echo PHP_EOL;



gives me:



string(0) ""

string(441) "Usage: wcutil [-s] [-d] [-x] [filename(*)]

    -s(imple)      Do not display CSV headers or average.

    -x(ml)         Xml output.

    -d(rophighlow) Drop highest and lowest path runs.



Column details:

    file   - output filename

    tps    - transactions per second

    kcpt   - kilocycles per transaction (aka 'path')

    bpt    - bytes per transaction

    cpu    - percent CPU utilization

    err    - count of any errors



"

string(0) ""



exec:



Array

(

    [0] => Usage: wcutil [-s] [-d] [-x] [filename(*)]

    [1] =>     -s(imple)      Do not display CSV headers or average.

    [2] =>     -x(ml)         Xml output.

    [3] =>     -d(rophighlow) Drop highest and lowest path runs.

    [4] =>

    [5] => Column details:

    [6] =>     file   - output filename

    [7] =>     tps    - transactions per second

    [8] =>     kcpt   - kilocycles per transaction (aka 'path')

    [9] =>     bpt    - bytes per transaction

    [10] =>     cpu    - percent CPU utilization

    [11] =>     err    - count of any errors

    [12] =>

)



which is correct.



Using 5.3.5 and 5.3-svn or trunk, on Windows 7/2003/2008.



Please try again and let me know if it still fails, using this exact
sample (can 

be other command), or repost an example to reproduce it. I will also
need to 

know which windows version you use.


Previous Comments:
------------------------------------------------------------------------
[2011-01-26 16:27:21] xc at ez dot no

Can someone speed up the fix? We have issue in our project based on this
bug.



I assume second call in the example should work..



Related issue: https://issues.apache.org/jira/browse/ZETACOMP-48



Thanks.

------------------------------------------------------------------------
[2010-04-23 08:46:52] David dot Gausmann at measx dot com

This is the same problem as mine:



$Command = '""c:\program files\doxygen\bin\doxygen.exe"
"C:\fred\doxyfile""';



$DescriptorSpecification = array

(

   0 => array('pipe', 'r'),

   1 => array('pipe', 'w'),

   2 => array('pipe', 'w')

);



$Resource = proc_open($Command, $DescriptorSpecification, $Pipes, null,
$_ENV);



Works fine (because it has the nasty double quotes around everything).

------------------------------------------------------------------------
[2010-04-23 02:22:47] xandrani at googlemail dot com

The double backward slashes didn't show correctly... but they are in my
code.

------------------------------------------------------------------------
[2010-04-23 02:20:33] xandrani at googlemail dot com

Something similar fails for me... but even worse!



$Command = '"c:\program files\doxygen\bin\doxygen.exe"
"C:\fred\doxyfile"'



$DescriptorSpecification = array

(

   0 => array('pipe', 'r'),

   1 => array('pipe', 'w'),

   2 => array('pipe', 'w')

);



$Resource = proc_open($Command, $DescriptorSpecification, $Pipes, null,
$_ENV);



I get the error:

'c:\program' is not recognized as an internal or external command,
operable program or batch file.



This works on exec() so not sure what's going on.

------------------------------------------------------------------------
[2009-08-03 13:09:56] david dot gausmann at measx dot com

Description:
------------
The command, which shall be executed via proc_open, must be put in
double quotes.

This bug was on functions like system, exec, ...

It seems not to be fixed on proc_open.

Reproduce code:
---------------
--- script1.php ---

<?php



  //Works fine

  echo "1.\r\n";

  system('"C:\php\php.exe" "C:\php\script2.php"');

  

  //FAILS!

  echo "2.\r\n";

  $arPipes = array();

  $rProcess = proc_open('"C:\php\php.exe" "C:\php\script2.php"', 

                  array(array('pipe', 'r'), array('pipe', 'w'),
array('pipe', 'w')), $arPipes);

  if($rProcess !== false)

  {

    $nExitCode = -1;

    do

    {

      while(!feof($arPipes[1]))

      {

        echo fread($arPipes[1], 1024);

        flush();

      }

      $array = proc_get_status($rProcess);

      if(!$array)

        break;

    } while($array['running']);

    fclose($arPipes[0]);

    fclose($arPipes[1]);

    fclose($arPipes[2]);

    proc_close($rProcess);

  }

  

  //Works fine (double quotes added)

  echo "3.\r\n";

  $arPipes = array();

  $rProcess = proc_open('""C:\php\php.exe" "C:\php\script2.php""', 

                  array(array('pipe', 'r'), array('pipe', 'w'),
array('pipe', 'w')), $arPipes);

  if($rProcess !== false)

  {

    $nExitCode = -1;

    do

    {

      while(!feof($arPipes[1]))

      {

        echo fread($arPipes[1], 1024);

        flush();

      }

      $array = proc_get_status($rProcess);

      if(!$array)

        break;

    } while($array['running']);

    fclose($arPipes[0]);

    fclose($arPipes[1]);

    fclose($arPipes[2]);

    proc_close($rProcess);

  }





?>

---script2.php---

<?php



  echo "Lorem ipsum\r\n";

  exit(0);



?>

Expected result:
----------------
1.

Lorem ipsum

2.

Lorem ipsum

3.



The third call of proc_open should fail, the second one should work.

Actual result:
--------------
1.

Lorem ipsum

2.

3.

Lorem ipsum



The second call of proc_open should fails, but the third one works.


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=49139&edit=1

Reply via email to