ID:               12300
 Comment by:       me at me dot com
 Reported By:      marv at cyberia dot net dot lb
 Status:           Bogus
 Bug Type:         Program Execution
 Operating System: WinXP
 PHP Version:      4.3
 New Comment:

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

hello.php:
echo hello;

on command line this works fine.

But when i tried :

$cmd="test.bat";
echo "Executing command: [$cmd]\n";
system($cmd,$value);
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 :)


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

[2003-04-25 04:47:54] mellott at tin dot it

very good work marv, I have lost a lot of time for this problem.

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

[2002-12-08 03:20:32] [EMAIL PROTECTED]

Not PHP bug.


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

[2002-12-07 09:24:41] 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-06 20:00:54] [EMAIL PROTECTED]

Try this:

<?php

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

?>

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

[2002-11-05 06:08:28] twa at carlbro dot dk

Maybe this bug duplicates this one:
http://bugs.php.net/bug.php?id=18958

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

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/12300

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

Reply via email to