Issue
Here is my ant script that wants to convert the script to executable from a zip. Here is what I do:
<chmod dir="tmp/temp/test/bin" perm="ugo+rx" includes="**/*" />
<echo message="Making scripts exec: tmp/temp/test/bin" />
<exec executable="/bin/bash">
<arg value="tmp/temp/test/bin/pkg"/>
<arg value="validate"/>
</exec>
This does not make the script executable and instead gives this error:
Execute failed: java.io.IOException: Cannot run program "D:\tmp\temp\test\bin": CreateProcess error=5, Access is denied.
Solution
Cannot run program "D:\tmp\temp\test\bin": CreateProcess error=5, Access is denied.
Are you running this under Windows or Linux/Unix/MacOS?
Windows doesn't have the concept of executability in a file. Instead, it associates file suffixes with executable programs. For example, I could associate the .py
suffix to be associated with the python.exe
program. Opening foo.py
will run that Python script under the Python executable. Change the name to foo.pl
, and either the script won't run, or if you've associated .pl
with perl.exe
, will run the script under Perl.
You can add the suffix of your script to the %PATHEXT%
environment variable which will allow you to type the file name sans extension. For example, if I added .py
to %PATHEXT%
, and I type in foo
into the command line terminal, Windows may look for foo.py
and then execute that. (unless it finds foo.exe
or foo.bat
first. Then those would execute).
The <chmod>
task does nothing under Windows. In the <chmod>
man page, it states:
Changes the permissions of a file or all files inside specified directories. Right now it has effect only under Unix or NonStop Kernel (Tandem).
Also, not all Zip implementations can store file permission and ownership information -- especially Unix style permissions and ownership. Some can, and some can't. Even if you somehow want to express the file's executability for Unix systems, it may not work.
What I recommend is to include a <condition>
test in your script to test for the OS. Then, you can separate what to do if you're on Linux/Windows/MacOS and what you want to do on a Windows system.
Answered By - David W. Answer Checked By - Senaida (WPSolving Volunteer)