|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12300 exec() family problems
Submitted: 2001-07-21 14:41 UTC Modified: 2002-12-08 03:20 UTC
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:3 (50.0%)
From: marv at cyberia dot net dot lb Assigned:
Status: Not a bug Package: Program Execution
PHP Version: 4.3 OS: WinXP
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.
Block user comment
Status: Assign to:
Bug Type:
From: marv at cyberia dot net dot lb
New email:
PHP Version: OS:


 [2001-07-21 14:41 UTC] marv at cyberia dot net dot lb
exec(), system(), etc. cause php to hang when called through the browser. when executed from the command line, it works fine.

I'm running PHP4.06, PWS, Win98SE. I'm using the PHP binary downloaded from

I have a batch file, test.bat which contains one line:
echo Hello

My PHP script is:

echo "Executing command: [$cmd]\n";
echo "Return value is: $value\n";

When I run this from the command line, ie. php test.bat, it works as expected. When I call the script from the browser, a command window opens and closes quickly, I get no output in the browser and the browser keeps trying to load the script. If I hit stop, the browser stops with nothing retrieved at all. PHP is still listed in the task list when pressing CTRL+ALT+DEL.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-24 06:30 UTC]
Can you try the latest CVS? Or a development-binary from

Does this problem still occur?
 [2001-10-24 09:02 UTC] marv at cyberia dot net dot lb
Tried it on 4.0.7, 4.1RC1a (with the win patch) and 4.2-dev
Failed on the lot of them with same behaviour (works in the command prompt, hangs in the browser).

 [2002-09-20 19:53 UTC]
Please try using this CVS snapshot:
For Windows:

 [2002-09-21 09:02 UTC] marv at cyberia dot net dot lb
one year later :)

i've switched to a WinXP system. from the people who have posted successful runs of system() and exec() on w2k and xp i thought it would work.

however, it DOESN'T. i downloaded the latest dev version and tried that. and it still doesn't happen.

it works fine in the command prompt (with php.exe and php-cgi.exe). but in the browser (which uses php-cgi.exe) it gives the following:
Warning: system() [function.system]: Unable to fork [D:\Website\projects\testbed\test.bat] in D:\Website\projects\testbed\test.phpdev on line 6

so it doesn't hang the browser anymore but maybe that's because of xp's shoot to kill policy.

i tried fiddiling with the permissions to see if its the cause. but even with the most liberal permissions it gives the same result.
 [2002-09-26 04:12 UTC] stepan dot rybar at taskforce dot cz
Yes, I have the same problem. For previous 24 hours I am trying to execute any program using exec, shell_exec, passthru... and Unable to fork or unable to execute. I have set up both IIS 5.1 and php.ini as unsecure as possible (temporary ;-) and no success. But I was successful on MS Windows ME, Apache 1.3.? and PHP 4.1.? for more than one year. So I am not sure, if it is not IIS configuration problem or problem with new directive in php.ini - cgi.something. I am running PHP 4.2.3 as a module. 

 [2002-11-05 06:08 UTC] twa at carlbro dot dk
Maybe this bug duplicates this one:
 [2002-12-06 20:00 UTC]
Try this:


$cmd="c:\\winnt\\system32\\cmd.exe /c test.bat";
echo "Executing command: [$cmd]\n";
echo "Return value is: $value\n";

 [2002-12-07 09:24 UTC] marv at cyberia dot net dot lb
finally got it to work! i couldn't make PHP use cmd.exe in the system32 directory since its not allowed to read from that directory. however, i copied cmd.exe into the script's directory and it worked. putting cmd.exe in php.exe's directory also worked. and i dont need to specify the command as "cmd.exe /c test.bat". using just "test.bat" works just fine.

so i guess the whole issue is having cmd.exe readable to php.exe and the simplest way to do that is placing cmd.exe in php.exe's directory. making system32 readable to PHP wouldn't very secure, since you would have to make it readable to all webserver processes.
 [2002-12-08 03:20 UTC]
Not PHP bug.

 [2003-04-25 04:47 UTC] mellott at tin dot it
very good work marv, I have lost a lot of time for this problem.
 [2004-01-30 11:00 UTC] me at me dot com
I'm having the same problem with exec. 
Am using php 4.2.2 with apache2 on win XP.

I am trying to open another .php page using exec.

Batch file: test.bat
c:/php/php.exe c:/php/hello.php

echo hello;

on command line this works fine.

But when i tried :

echo "Executing command: [$cmd]\n";
echo "Return value is: $value\n";

Browser hangs and when i did ctl+alt+del it shows lots of cmd and php.exe processes.

However if the test.bat file was :
echo hello

then it works fine.
Any ideas appreciated :)
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 09:01:23 2020 UTC