我在 Apache/2.2.16 (Win32) 上运行 PHP 5.2.14,并且我有一个脚本来运行一个 shell 命令,当在命令提示符下测试时效果很好,但在浏览器模式 (html) 下,它没有。
脚本:
我的batfile.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
任何帮助和建议表示赞赏。鲁夫鲁