PHP Shell exec在html浏览器中不起作用,但在cmd提示符下起作用 [英] PHP shell exec not working in html browser but working on cmd prompt

查看:74
本文介绍了PHP Shell exec在html浏览器中不起作用,但在cmd提示符下起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Apache/2.2.16(Win32)上运行PHP 5.2.14,并且我有一个脚本可以运行shell命令,当在命令提示符下测试该脚本效果很好,但在浏览器模式(html)下却不能.

I am running PHP 5.2.14 on Apache/2.2.16 (Win32) and I have a script to run a shell command, which when tested in the command prompt works well but in browser mode (html), it doesnt.

mybatfile.bat

REM ...
REM process some folder details
REM code which does not work in browser mode but works in cmd mode
C:/somfolder/bin/mysqldump -u abc -pabcdef --result-file="C:/Apache22/somfolder/DBbackup/DBbackup.%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%.sql" --dump-date  --log-error="C:/Apache22/somfolder/DBbackup/DBbackup.%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%.log" dbname > dboutputresult.txt

REM process result of savedfile

calltobatfile.php

//process some folder information
$file = file_get_contents($folderroot."/exec/mybatfile.bat");
//var_dump($file);
    $strarr = explode("\n", $file);
    foreach($strarr as $line){
      if(strlen($line)>1){
        var_dump("line: ".$line."\n"); 
        $output = shell_exec($line);
        print_r($output);
     }
   }

//process result of savedfile additional information

任何帮助和建议表示赞赏. 卢夫(Luhfluh)

any help and suggestions appreciated. Luhfluh

推荐答案

检查权限以将其作为服务器运行.您可以以所有者身份运行它,但无法以其他用户身份运行它-在您的示例中以apache运行.

Check the permissions to run it as a server. You can run this as owner, but there can be no possibilities to run it as other user - in your example as apache.

这篇关于PHP Shell exec在html浏览器中不起作用,但在cmd提示符下起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆