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

Calling an ExtendScript script from the command line

Community Expert ,
Jan 08, 2015 Jan 08, 2015

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

1.3K

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
Mentor ,
Jan 09, 2015 Jan 09, 2015

Copy link to clipboard

Copied

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

Votes

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
Community Expert ,
Jan 09, 2015 Jan 09, 2015

Copy link to clipboard

Copied

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

Votes

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
Mentor ,
Jan 09, 2015 Jan 09, 2015

Copy link to clipboard

Copied

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

Votes

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
Community Expert ,
Jan 09, 2015 Jan 09, 2015

Copy link to clipboard

Copied

I think you might be onto something with this approach. Mif2Go might even be able to write the output path to a text file and my script could fish it out of there. I will keep you posted. Thanks for the ideas.

Votes

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
New Here ,
Jan 06, 2016 Jan 06, 2016

Copy link to clipboard

Copied

LATEST

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()).

Votes

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