gpt4 book ai didi

php shell_exec bash.exe 在 Window XP IIS 中不工作

转载 作者:可可西里 更新时间:2023-11-01 01:02:20 26 4
gpt4 key购买 nike

生成的b.php

 <?php
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
echo 'This is a server using Windows!';
$output = shell_exec("C:\\cygwin\\bin\\bash.exe --login -c C:\\cygwin\\bin\\mysql2sqlite.sh -h 127.0.0.1 -u root -pApacheah64 db_shuttlebus tbl_driver tbl_location tbl_rate tbl_route tbl_routeid tbl_vehicle | C:\\cygwin\\sqlite3.exe C:\\Inetpub\\wwwroot\\BusTicket\\exportdatabase\\database.sqlite");
echo "<pre>".$output."</pre>";
} else {
echo 'This is a server not using Windows!';
$output = shell_exec("bash mysql2sqlite.sh -h 127.0.0.1 -u root -pApacheah64 db_shuttlebus tbl_driver tbl_location tbl_rate tbl_route tbl_routeid tbl_vehicle | sqlite3 /var/www/BusTicket/exportdatabase/database.sqlite");
echo "<pre>".$output."</pre>";
}

?>

这是输出的错误

Warning: shell_exec(): Unable to execute 'C:\cygwin\bin\bash.exe --login -c
C:\cygwin\bin\mysql2sqlite.sh -h 127.0.0.1 -u root -pApacheah64 db_shuttlebus tbl_driver
tbl_location tbl_rate tbl_route tbl_routeid tbl_vehicle | C:\cygwin\sqlite3.exe
C:\Inetpub\wwwroot\BusTicket\exportdatabase\database.sqlite' in
C:\Inetpub\wwwroot\BusTicket\exportdatabase\generatedb.php on line 4

如果我手动打开 cmmand promt 并运行命令工作正常,但在 PHP 中则无法工作。为什么?

我已经检查过 php.ini 安全模式已关闭且 disable_functions = 为空白。

这是我的 phpinfo.php

enter image description here

这是我正在使用 cmd.exe 运行命令,它正在运行

enter image description here

最佳答案

了解IIS,大概有多种可能的解释。这是我在 http://www.php.net/shell_exec 上找到的一个

Got the error "Unable to execute..." when trying to run an external program with shell_exec under Windows XP, IIS 5, php 4.3.7 Solved by giving the IIS user (IUSR_...) execution privileges on the system file %systemroot%\system32\cmd.exe This should be used carefully because may represent a server's security hole.

HTH.

关于php shell_exec bash.exe 在 Window XP IIS 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20633380/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com