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

How to call the JSX code within ShellScript?

Community Beginner ,
Oct 25, 2021 Oct 25, 2021

Hi All,

 

I have a code for PDF export. I wanted to call this code/file within shellscript.

#targetengine "session"
exportPDF();

function exportPDF() {
    var fileid = Date.now();
    var targetFile = new File(Folder.temp.absoluteURI + "/" + fileid);
    //preset
    var PDFpreset = getPDFPreset();
    var docs = app.documents[0];
    docs.exportFile(ExportFormat.pdfType, targetFile, false, PDFpreset);
}

function getPDFPreset() {
    var myPrefs = myPrefs = app.pdfExportPresets.add();
    myPrefs.name = "expPDF";
    return myPrefs;
}

Could anyone help me on this request.

 

Thanks. 

TOPICS
How to , Scripting
812
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 Beginner ,
Oct 25, 2021 Oct 25, 2021

Note: I want to execute the JSX code within shell script for both Mac and Windows OS.

 

 

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
Advisor ,
Oct 25, 2021 Oct 25, 2021

Hello @anna duraim38716857,

This works on Mac OS, you will just need to change the file path and name of the .jsx file.

osascript -e 'tell application id "com.adobe.indesign" to do script (posix file "/Users/User-Name/Desktop/Your-Script.jsx") language javascript'

 

For Windows see the post below.

https://community.adobe.com/t5/after-effects-discussions/run-jsx-file-from-command-line-windows/td-p...

 

Regards,

Mike

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 Beginner ,
Oct 26, 2021 Oct 26, 2021

Thank you Mike. Is that mandatory to use the applescript code for mac?

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
Advisor ,
Oct 27, 2021 Oct 27, 2021

Hello @ad_ind38716857,

 

Re: This works on Mac OS, you will just need to change the file path and name of the .jsx file.

osascript -e 'tell application id "com.adobe.indesign" to do script (posix file "/Users/User-Name/Desktop/Your-Script.jsx") language javascript'

You don't run the above code as an Applescript, copy and paste into the Terminal app to execute.

osascript is a command to run the script from the shell.

Regards,

Mike

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
LEGEND ,
Oct 27, 2021 Oct 27, 2021

Sadly though, this does use AppleScript to run the JavaScript. This means it's subject to Apple's byzantine security preferences. (I wouldn't mind them, except that I find they keep turning off when I'm in the middle of a live session).

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
Advocate ,
Oct 27, 2021 Oct 27, 2021

As far as windows is concerned, you can do like this with VBscript :

 

Set myInDesign = CreateObject("InDesignServer.Application")
Set myInDesign = GetObject("configuration_12345")
myJavaScript =  "app.doScript(File('C:/Users/sunil/Desktop/test.jsx'));"
myInDesign.DoScript myJavaScript, 1246973031

 

I am not good with appleScript, so can not say much about that.

 

Note  : "configuartion_12345" here "12345" is port number of session created for InDesign Server.

 

Best

Sunil

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 Beginner ,
Oct 28, 2021 Oct 28, 2021

Thank you Sunil for your reply. But I want to call the JSX script file with in the Shell script. Is that possible?

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
Advocate ,
Oct 29, 2021 Oct 29, 2021

See VB script,

I have executed JSX script from VBscript targeting a session of InDesign Server,

Same way you also might do it using Shell Script.

 

Sunil

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 Beginner ,
Nov 02, 2021 Nov 02, 2021

Hi Sunil,

 

Sorry for the late reply. Honestly, I don't know how to use it from shell script. Do you have any idea on that?

 

Thanks.

 

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
Advocate ,
Nov 02, 2021 Nov 02, 2021
LATEST

When we sit on discussion definetly we will find some solution fro sure.

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