php exec:不返回输出 [英] php exec: does not return output
问题描述
我有这个问题:
在ISS网络服务器上,安装了Windows 7 x64 professional,zend服务器。在php下运行此命令:
I have this problem: On a ISS web server, windows 7 x64 professional, zend server installed. Running this command under php:
exec('dir',$output, $err);
$ output为空,$ err = 1.
所以exec没有回退输出,似乎有一些错误。
Php disable_functions
是空的,php不是安全模式,是标准的,我检查所有选项。
这似乎是一般性错误,即使是谷歌搜索也不会给出结果。
$output is empty, $err=1.
So exec is not returing the output, it seems has some errors.
Php disable_functions
is empty, php is not on safe mode, is standard, I check all option.
It seems to be a general errors, even search on google do not give results.
请写下他的经验和最终解决方案或解决方法。
Please write every one his experince and eventual solutions or workarounds.
推荐答案
PHP手册的相关部分有一些帖子,例如这一个:
There are a few posts to the relevant sections of the PHP Manual such as this one:
我无法使用PHP exec命令执行任何批处理
文件。执行其他命令(即dir)工作正常。但是如果我
执行了一个批处理文件,我收到了exec命令的输出。
I was having trouble using the PHP exec command to execute any batch file. Executing other commands (i.e., "dir") works fine). But if I executed a batch file, I receieved no output from the exec command.
我的服务器设置包括运行
IIS6和PHP 5.2.3的Windows Server 2003服务器。在这台服务器上,我有:
The server setup I have consists of Windows Server 2003 server running IIS6 and PHP 5.2.3. On this server, I have:
- 对c:\windows \ system32 \ cmd.exe上的Internet用户授予执行权限。
- 授予所有人 - >完全控制编写批处理文件的目录。
- 授予每个人 - >完全控制整个c :\ cygwin \ bin目录及其内容。
- 授予Internet用户以批处理方式登录权限。
- 指定完整路径
- 测试了从服务器上的命令行运行的这些脚本,它们工作得很好。
- 确保%systemroot% \ system32在系统路径中。
- Granted execute permissions to the Internet User on c:\windows\system32\cmd.exe.
- Granted Everyone->Full Control to the directory in which the batch file is written.
- Granted Everyone->Full Control on the entire c:\cygwin\bin directory and its contents.
- Granted the Internet User "log on as batch" permissions.
- Specified the full path to each file being executed.
- Tested these scripts running from the command line on the server and they work just fine.
- Ensured that %systemroot%\system32 is in the system path.
事实证明,即使在服务器上安装了以上所有内容,我也是如此b $ b必须在exec调用中指定cmd.exe的完整路径。
It turns out that even with all of the above in place on the server, I had to specify the full path to cmd.exe in the exec call.
当我使用调用时: $ output = exec( C:\\windows\\system32\\cmd.exe
/ c $ batchFileToRun);
然后一切正常。在我的情况下, $ batchFileToRun
是批处理文件的
实际系统路径(即调用
realpath()的结果)。
then everything worked fine. In my situation, $batchFileToRun
was the
actual system path to the batch file (i.e., the result of a call to
realpath()).
exec
和 shell_exec
手册页。也许通过它们可以得到它并为你工作。
There are a few more on both the exec
and shell_exec
manual pages. Perhaps following through them will get it up and working for you.
这篇关于php exec:不返回输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!