How to enable execute privileges on a file on OSX

Explorer ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

Hello!
I'm creating a .command file from my illustrator extend script to interact with the terminal. But when I try to do file.execute() it's telling me that it can't be executed since I don't have the appropriate access privileges.
This can be fixed manually if edit the file and do something like chmod u+x 777 on the .command file, but for this script it needs to create and delete the command file when necessary.

This is how I create the file

function writeFile(fileObj, fileContent) {
    encoding = "utf-8";
    fileObj = (fileObj instanceof File) ? fileObj : new File(fileObj);
    fileObj.encoding = encoding;
    fileObj.open("w");
    fileObj.write(fileContent);
    fileObj.close();
    return fileObj;
}

 Maybe there is some encoding that can be done? Any ideas?

TOPICS
How to, Scripting, Tools

Views

161

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

What I did for one of my projects is create a .command file manually and give it execute access using the chmod command. Then in the script I used this base .command file, opened it wrote the new commands saved it, and then executed it. Hope that works for you as well

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

Hello Manan,
This could be a potential solution. Currently my script creates and destroys this .command file during runtime and it works fine on windows. I'd have to refactor some code but it could work.
I am still curious if there is a way to set the permissions of the file at creation though, but thanks for the answer.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 31, 2021 May 31, 2021

Copy link to clipboard

Copied

LATEST

I was not able to find any other way. One possible approach could be to create the file, use Applescript to change its permission(I think we can launch AS from within JS). I would be interested to know what you finally come up with.

-Manan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines