我正在尝试从我的 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\.sh
和 HKCR\sh_auto_file
的注册表。
您可以为此使用 regedit
。
关于php - 从 php 执行 shell 脚本在 Windows (Xampp) 上打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22812002/