Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to enable execute privileges on a file on OSX

Explorer ,
May 31, 2021 May 31, 2021

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
Scripting , Tools
487
Translate
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 Expert ,
May 31, 2021 May 31, 2021

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

Translate
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

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.

Translate
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
Community Expert ,
May 31, 2021 May 31, 2021
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

Translate
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