php exec:不返回输出

前端之家收集整理的这篇文章主要介绍了php exec:不返回输出前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个问题:
在ISS Web服务器上,安装了 Windows 7 x64专业版,zend服务器.在PHP下运行此命令:
exec('dir',$output,$err);

$output为空,$err = 1.所以exec不会退出输出,似乎有一些错误.
PHP disable_functions为空,PHP不在安全模式下,是标准的,我检查所有选项.
这似乎是一般的错误,即使在谷歌搜索也没有给出结果.

请写下每一个他的经验和最终的解决方案或解决方法.

PHP手册的相关章节有一些帖子,如 this one

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.

The server setup I have consists of Windows Server 2003 server running
IIS6 and PHP 5.2.3. On this server,I have:

  1. Granted execute permissions to the Internet User on c:\windows\system32\cmd.exe.
  2. Granted Everyone->Full Control to the directory in which the batch file is written.
  3. Granted Everyone->Full Control on the entire c:\cygwin\bin directory and its contents.
  4. Granted the Internet User “log on as batch” permissions.
  5. Specified the full path to each file being executed.
  6. Tested these scripts running from the command line on the server and they work just fine.
  7. Ensured that %systemroot%\system32 is in the system path.

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.

When I used the call: $output = exec("c:\\windows\\system32\\cmd.exe
/c $batchFileToRun");

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()).

execshell_exec手册页上还有更多的内容.也许跟随他们将会得到它并为你工作.

原文链接:https://www.f2er.com/php/131654.html

猜你在找的PHP相关文章