#22662 [Opn]: shell_exec not working on windows XP
| From: | pjaleysen at hotmail dot com | Date: | Wed, 12 Mar 2003 17:58:59 +0000 |
| Subject: | #22662 [Opn]: shell_exec not working on windows XP | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-35448@lists.php.net to get a copy of this message | ||
ID: 22662
User updated by: pjaleysen at hotmail dot com
Reported By: pjaleysen at hotmail dot com
Status: Open
Bug Type: Output Control
Operating System: Windows XP
PHP Version: 4.2.3
New Comment:
like I said, the native Windows commands work correctly. I tried
putting cmd before a command, but invain.
This is a brief summary of the forum thread, found at
http://forums.devshed.com/t55038/s.html):
//---------------------------------------------------
I am trying to use pkzip to compress documents.
I am running a windows PC, so I am trying to execute a DOS command.
I have so far:
<?php
$pkzip="C:/Progra~1/Apache~1/Apache/readwr~1/pkzip.exe";
$pkzipdirectory="C:/Progra~1/Apache~1/Apache/readwr~1/";
$command=$pkzip." ".$pkzipdirectory."myzip.zip"."
".$pkzipdirectory."mydoc.doc";
shell_exec($command);
?>
It doesnt work
//---------------------------------------------------------
shouldn't have to as long as cmd.exe is in your path.
can't believe its not really.
maybe try a little test like this and see what you get back,
then you'll know if its a path problem.....
<?php
$test = shell_exec("ping 192.168.0.1");
echo $test;
?>
//------------------------------------------------------
The ping works ok!
I can do the standard commands alright.
I tried:
1)using absolute directories (like above)
2) changing path=, to include the pkzip file (A dos version of pkzip)
3) changing to the 'long' directory notation (e.g progra~1 => program
files)
//-------------------------------------------------
Executing commands in the shell from a PHP script only works
when the program you are trying to execute resides in your
system directory (windows 2000: c:\winnt\system32).
//-----------------------------------------
I might have a clue!?!?
e.g. I have a batchfile saying:
"echo this batchfile works"
running this with:
<?php
$test=shell_exec("run.bat ");
echo $test;
?>
echoos 'echo this batchfile works'
Shouldnt the 'echo' NOT be there in the echo $test?
It's like it is just reading the line, instead of executing it.......
//------------------------
Previous Comments:
------------------------------------------------------------------------
[2003-03-12 11:47:40] andrew@php.net
Sorry, that should be shell_exec('cmd ver');
~ Andrew Heebner
------------------------------------------------------------------------
[2003-03-12 11:45:52] andrew@php.net
How are you passing your params to shell_exec() ?
I know from personal experience, that shell_exec() requires me to load
command.com to the interpreter, such as:
print shell_exec('cmd version');
This *should* print out your windows version...
~ Andrew Heebner
------------------------------------------------------------------------
[2003-03-12 11:33:24] pjaleysen at hotmail dot com
Hi,
shell_exec(),as well as exec(),system(), can only handle 'native' DOS
applications like ping,copy,attrib etc.
either directly as a command, or though a *.bat file.
Executing other (DOS) applications like pkzip (for DOS) or (rar for
dos) don't seem to work.
There is a thread of this issue at www.devshed.com
(http://forums.devshed.com/t55038/s.html)
I am using:
-Windows XP
-Apache 1.3.27
-PHP4.3
All with the default configurations.
Kind regards
Patrick
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22662&edit=1