Skip to main content
frameexpert
Community Expert
Community Expert
January 8, 2015
Question

Calling an ExtendScript script from the command line

  • January 8, 2015
  • 2 replies
  • 1481 views

Hi! I can call an ExtendScript script from a command line just by using its path, but is there a way to pass parameters to the script? Thanks. -Rick

This topic has been closed for replies.

2 replies

Participant
January 6, 2016

How do you call a script from the command line? I tried passing HelloWorld.jsx as the first parameter to FrameMaker.exe, but it didn't recognise the file type

I agree that modifying wrapping the script in some other scripting language before launching should do the trick for you. I would simply write a simple program that assigns the variables you need by prepending them at the top of the document (since that would be the entry point when there is no main()).

Legend
January 9, 2015

Hi Rick,

What is a "parameter," in the context of an ExtendScript? A script has no standard entry point, like a main() function, etc., to accept parameters. So, I'm not clear what it is you are trying to set. A script could start out by reading some text file of data, but you already know that.

On a web page, you can pass in parameters to javascript via the URL or the POST body, but these are functions of the HTTP protocol and the web server app, not the scripting language.

Russ

frameexpert
Community Expert
Community Expert
January 9, 2015

Hi Russ, I have a potential client that is using Mif2Go to output HTML from FrameMaker. The HTML has tags that have line breaks between the open tag and the first attribute. Normally, this isn't a problem, but in one of their downstream processes it is. So, I wrote a simple ExtendScript that processes all of the HTML files in a folder and "flattens" the line breaks within tags. Currently, you run the script from FrameMaker and it prompts you for the HTML folder. Mif2Go can do a command line call automatically when it finishes outputting the HTML files. I was trying to figure out a way to call the script and pass in the output folder. -Rick

www.frameexpert.com
Legend
January 9, 2015

Hi Rick,

Well, a scan of the documentation certainly provides no evidence of this capability. If it exists, someone else will have to fill us in.

I did have an idea, although it's a bit of a roundabout approach. A windows batch file can accept parameters and can write a text file. So, maybe Mif2Go can call a batch file instead that writes the folder to some file, then runs the script that reads the file. Although, I'm not familiar with a command line call to ES, so I'm not sure that a batch file can launch an ES script too. If not, can Mif2Go make more than one command line call?

Russ