3


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?

3
  • I have next to no experience with MS-Windows, but are you sure that the unix typical 2>&1 can be used under that system? Also might be worth exploring what "default application" is registered inside the system to handle "*.sh" files. Commented Apr 2, 2014 at 12:57
  • Yes, I think so. the 2>&1 seemed to work the last time I checked. Without the 2>&1 it opens a notepad aswell. I'll have a look at the windows .sh handler Commented Apr 2, 2014 at 13:08
  • 2>&1 works with both windows (cmd) & linux (*sh) Commented Apr 2, 2014 at 13:08

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thenks. You got me on the right track. Still trying to get it to work, but now I know where to look!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.