On Thu, 23 Sep 2004 16:41:39 +0200, "Thomas Mlynarczyk"
<bl*************@hotmail.com> wrote:
I run PHP 4.3 as an Apache module. I use Apache 1.3 as a service under
WinXP. And I've got a strange problem with exec():
The following commands are executed correctly:
c:\windows\system32\cmd.exe /?
c:\apache\apache.exe -w -n "Apache" -k restart
The following commands are not executed (empty output array, return code =
1):
c:\Apache\Apache.exe -h
c:\windows\system32\cmd.exe /C c:\apache\apache.exe -h
It works with the console, however. So why not with PHP?
This is in fact consistent - the commands ARE being run. The convention for
'usage' commands is to output the usage information on standard error and NOT
standard output, and to exit with a non-zero (failure) error code.
D:\Apache2\bin>apache.exe -h
Usage: apache.exe [-D name] [-d directory] [-f file]
[-C "directive"] [-c "directive"]
[-w] [-k start|restart|stop|shutdown]
[-k install|config|uninstall] [-n service_name]
[-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
-D name : define a name for use in <IfDefine name> directives
[ ... snip ... ]
-t : run syntax check for config files
D:\Apache2\bin>echo %ERRORLEVEL%
1
There's your '1' return code.
D:\Apache2\bin>apache.exe -h 2>NUL
D:\Apache2\bin>
Redirecting standard error shows that there's nothing sent to standard output.
--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool