ID:               41874
 User updated by:  ckeefer at us dot nomura dot com
 Reported By:      ckeefer at us dot nomura dot com
 Status:           Assigned
 Bug Type:         Feature/Change Request
 Operating System: Windows XP Pro SP2
 PHP Version:      5.2CVS-2007-07-03
 Assigned To:      jani
 New Comment:

I don't actually see how this is an improvement as output was only
mixed if you don't redirect, which is expected.  If I do something like
php progname.php > logfile.txt, I would previously redirect STDIN to the
logfile as expected and stderr would still come to the console so I
could monitor the program's progress.  This is the usual behavior in
shell programs, etc.  This is how cmd line php was working through
version 5.21.  5.22 on changed behavior in that from Win32, the STDERR
disappears completely.  If you can tell me where STDERR went and how to
get to it from exec, I will happily do that.  I have hundreds (if not
thousands) of php scripts that do this.  This new behavior breaks all of
them.  If I do php progname.php 2>&1 > logfile.txt, even if this works,
I get mixed STDIN and STDERR output in the logfile.txt.  This will force
me to either stay at version 5.21 or earlier, or revise every script we
have that currently uses the exec function.

Again I ask: Did anything change with the compiler or other development
tools used to create the Window Binary?  Microsoft has been known to
modify libraries in undocumented ways.

Thanks
Chip Keefer


Previous Comments:
------------------------------------------------------------------------

[2007-07-18 14:55:27] [EMAIL PROTECTED]

Since this is actually improvement from previous behaviour where the
output was mixed, I'm changing this to a FR. I'll look into adding an
extra parameter to store STDERR in. In the meantime I suggest you use
proc_open() or popen() which give you more control over these..

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

[2007-07-18 13:01:40] ckeefer at us dot nomura dot com

>Oddly, 5.2.2+ versions still work correctly with cygwin/bash 3.1
Using the same Win32 binary, not a Cygwin binary.

To [EMAIL PROTECTED]:  That is a good suggestion for just getting STDERR
output and I use it often on Unix and Linux systems when I need, and
don't care if outputs are mixed.  I haven't tested if this construct
works with W32.  Unfortunately, I need STDIN and STDERR separate.

I also have a question:  Did the version of compiler or libraries used
to compile the binary change? MS is notorious for making undocumented
changes to their development tools.

Thanks,
Chip Keefer

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

[2007-07-18 08:45:45] [EMAIL PROTECTED]

This works fine with *nix (found from the user comments at
http://www.php.net/manual/en/function.exec.php :

<?php

$com= "ls foo";

exec("$com 2>&1", $out, $err);

var_dump($out);

?>

I don't know if Windows supports something like this, but iirc, it
should.


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

[2007-07-03 12:56:37] ckeefer at us dot nomura dot com

Thank you for the quick response.  The new version still shows no
STDERR output from a cmd.exe window.

Thanks

C:\php5.2fix>php test_exec.php
Two exec statements:
-------------------
This exec should result in error for non-existant dir:
Array
(
)
-----------------------
This exec works:
--------------------
Array
(
    [0] =>  Volume in drive C is LOCAL DISK
    [1] =>  Volume Serial Number is 4054-8345
    [2] =>
    [3] =>  Directory of C:\php5.2fix
    [4] =>
    [5] => 07/03/2007  08:08 AM            32,821 php.exe
    [6] =>                1 File(s)         32,821 bytes
    [7] =>                0 Dir(s)  58,549,849,088 bytes free
)

C:\php5.2fix>
C:\php5.2fix>type test_exec.php
<?php
echo "Two exec statements:\n-------------------\n";
echo "This exec should result in error for non-existant dir:\n";
exec("cd c:\\non_existant", $err);
print_r($err);
echo "-----------------------\n";
echo "This exec works:\n--------------------\n";
exec("dir php.exe", $ary);
print_r($ary);
?>

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

[2007-07-03 06:41:22] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi



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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/41874

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

Reply via email to