문제


I'm trying to run a script from my PHP file. When I run the script, it just opens my notepad instead of executing the file.
I have given my folder read and write permissions, tried to run via SSH (because I work with Vagrant) and via cmd. But nothing seems to work. I think my code is correct, which you can find bellow:

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

Someone who can help me out?

도움이 되었습니까?

해결책

It's because your OPEN WITH for .sh files is set to notepad.

Check below output:

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

You can change the association with:

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

(Change the path for bash.exe as per your setup...)

For more details, run commands assoc /? & ftype /? on cmd.exe. (/? is typical equivalent of -h or --help in Linux commands...)

Also, for more advanced users, check in registry for HKCR\.sh & HKCR\sh_auto_file. You can use regedit for it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top