Skip to main content
Participating Frequently
September 18, 2023
Question

Strange behaviour with #include with script ran from command line

  • September 18, 2023
  • 1 reply
  • 1491 views

I have a script that uses external JS libraries which I call by the #include directive; there are four of them, an example:

#include "D:/absolute/path/to/lib/papaparse.js"

Ultimately, I need to run the script from the command line; this I do with this command:

"C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\ExtendScript Toolkit.exe" -run "D:\absolute\path\myscript.jsx"

The problem is that the script does not run in its entirety and it stops just when a function from the external script is called. How do I know? I have the script to write logs to text files at certain points during its run.

When I run the script from the Extend Script ToolKit (ESTK)directly, it runs OK (ie. the functions from the external scripts are used without any issues). 

 

Why is there a problem when run from the command line and can it be resolved while still keeping external scripts linked to the main script? (I tried to copy all the code of the external scripts to the main script but it leads to some new problems that would take quite some time to resolve so I am trying to avoid this way if possible.)

 

Also, when trying to find out where the problem is I met with this behaviour for various forms of paths to the external scripts:

(1) paths to the external files relative (eg. /lib/papaparse.js) 

– runs OK from the ESTK

– from the command line, it only starts indesign but does not run further

 

(2) paths to the external files absolute (eg. D:/absolute/path/to/lib/papaparse.js) 

– runs OK from the ESTK

– from the command line, it runs but there are issues with loading the external files

 

Thanks for any advice.

 

This topic has been closed for replies.

1 reply

Participating Frequently
September 18, 2023

(This is an addition to the original post)

 

I copied all the code of the external libraries to the main script (the problems I mentioned before could be resolved just by placing the code at the beginning of the file). When run from ESTK, it runs fully. When run from the command line, it stops at the same point as it does when the libraries are placed externally and linked with absolute paths. Strange.

m1b
Community Expert
Community Expert
September 18, 2023

Interesting. Are you able to work out which line is causing the stopping?

Participating Frequently
September 18, 2023

Yes, I am. It is a deduction from strategically placing a function that logs the run of the script. It stops just when it is calling the Papaparse library for the first time.