php - 从 php 执行 shell 脚本在 Windows (Xampp) 上打开文件

标签 php bash shell laravel xampp


我正在尝试从我的 PHP 文件运行脚本。当我运行脚本时,它只是打开我的记事本而不是执行文件。
我已授予文件夹读写权限,尝试通过 SSH(因为我使用 Vagrant)和 cmd 运行。但似乎没有任何效果。我认为我的代码是正确的,您可以在下面找到:

$output = shell_exec(getcwd()."/scripts/row.sh 2>&1");

谁能帮帮我?

最佳答案

这是因为您的 OPEN WITH for .sh 文件设置为 notepad

检查以下输出:

my_prompt> assoc .sh
.sh=sh_auto_file
    ^ ^ ^ ^ ^ ^ ^ <~~~~~~ Remember this name

my_prompt> ftype sh_auto_file <~~~~~~~~~~Use it here
sh_auto_file=%SystemRoot%\system32\NOTEPAD.EXE %1

您可以更改关联:

my_prompt> ftype sh_auto_file=c:\cygwin\bin\bash.exe %1 %*

(根据您的设置更改 bash.exe 的路径...)

有关详细信息,请在 cmd.exe 上运行命令 assoc/?ftype/?。 (/? 是 Linux 命令中 -h--help 的典型等价物...)

此外,对于更高级的用户,请检查 HKCR\.shHKCR\sh_auto_file 的注册表。 您可以为此使用 regedit

关于php - 从 php 执行 shell 脚本在 Windows (Xampp) 上打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22812002/

相关文章:

bash:将脚本的输出作为脚本执行

cocoa - 如何使构建 Xcode 目标依赖于 shell 脚本?

php - 持续运行的 Gearman Worker

php - 从数据库加载多个对象

linux - 在 Bash shell 中设置自定义基本快捷方式

arrays - 如何使用 bash 或 python 从一组数字中搜索连续的数字

windows - 在 PATH 环境中拥有本地目录不安全?

shell - 双击执行shell脚本

php - 在分层 JSON 中添加字段

php - 更新存在超过 1 个最大值的数据库