php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32888 Problem executing external programs with different methods...
Submitted: 2005-04-29 10:34 UTC Modified: 2005-04-29 10:47 UTC
From: kaufmann at brainworxx dot de Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3.11 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kaufmann at brainworxx dot de
New email:
PHP Version: OS:

 

 [2005-04-29 10:34 UTC] kaufmann at brainworxx dot de
Description:
------------
Hello,

I am using Apache with latest php 4 release (also tried latest php4 cvs). I am having problems executing external programs using exec, system and also using proc_open.

While trying to execute using exec or system, the script just hangs off (but does not hook up the apache process).
Commands that are enabled in command.com (like dir) are working fine!

Using proc_open I encountered another problem. Executing at all works. Executing a script from command-line works, but calling the same script from url using apache doesn't (returns no result).
I figured out, that the default path for the programs is the apache-path, which seems to enforce this problem.

I was unable to change the path using the cwd-option refered to on php.net documentation. In this case the proc_open also just returns nothing.

Another problem I figured out was, that get_stream_contets hooks the script (even if it is working with fgets instead).


Reproduce code:
---------------
<?
pipe_spec = array(
                  0 => array("pipe", "r"),
                  1 => array("pipe", "w"),				  2 => array("file", "ziperrors.txt", "a")
		 );

// using proc_open
$process = proc_open('zip', $pipe_spec, $pipes,'c:\');
// for some reason get_stream_contents also hangs anyway!
while (!feof($pipes[1])) // read results
  { print fgets($pipes[1]); }
fclose($pipes[1]);
proc_close($process);


// using system / exec (same results with both of them)

exec('dir'); // works fine
exec('zip'); // script hangs / deadload
print `zip`; // using backticks causes also deadload
?>

Expected result:
----------------
I expect to get any result / execute of the programs executed

Actual result:
--------------
actual results are...

1) exec or system call causes hookup / deadload of script
2.a) proc_open works, but wrong execution path, unable to change exec_path using proc_open cwd-option
2.b) get_stream_contents also deadloads, needed to be replaced with fgets to get nearly any result at all.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-29 10:41 UTC] sniper@php.net
It's an windows issue, see the user comments at:
http://www.php.net/exec

 [2005-04-29 10:47 UTC] kaufmann at brainworxx dot de
hello,
thanks for your quick reply and help.
exec and system seem to work now after some tries!

proc_open is still buggy when changing the cwd-path,
also stream_get_contents still has issues as described.

Sincerly
Gabriel
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC