views:

236

answers:

1

I'm not running cygwin, but I have the cygwin ash.exe in my %PATH% as sh.exe and have cygwin1.dll in %PATH%

I am trying to invoke some shell scripts (named with no extension) using sh -c shell-script-name but I get a "permission denied" error. If I run sh and run ./script I also get this error. I have a proper #!/bin/sh shebang line and even renaming to .sh or .exe has no effect. What should I do?

+1  A: 

One thing to try to see if Windows permissions are causing a problem is to run Process Monitor and filter it for sh.exe and shell-script-name. That will probably show you if there's particular permission you don't have (eg you might have read but not execute permission).

Try also running the shell interactively, ie:

c:\>sh
sh# . ./script     or
sh# sh -c ./script

If this works then you know that the cygwin part is working correctly. Another thing to check is that the line endings for your script are unix, as that can stop scripts from executing correctly.

the_mandrill
Line endings are Unix./script fails. ./script succeedssh ./script succeedssh -c ./script failssh -c script fails
singpolyma
could it be that when you invoke sh that has the effect of changing the current working directory, so that it doesn't find the script? Try `sh -c pwd`
the_mandrill