Book a Demo

Author Topic: Call a external perl script from inside EA  (Read 5581 times)

orchidLAN

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Call a external perl script from inside EA
« on: January 08, 2016, 09:15:45 pm »
Hello everyone,

Background: there is a small project, which is first run a code generation to generate the code to an external file , then use external perl script to work with the code file and generate a report, finally go back to the internal EA and run the rest of the script. the first step and the third one is written in Javascript, and among these three steps there is no argument need to be transfered.

Question: would it be possible to call the perl script from inside the internal javascript so that I can merge these three steps into one.

Additionally: I can add this perl script with the step: Tools-->Customizes-->Tools as an extension application inside EA, but I do not know how to invoke it in javascript.

Anyone got any ideas?
Thanks in advance

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Call a external perl script from inside EA
« Reply #1 on: January 08, 2016, 09:54:30 pm »
I'm pretty sure that must be possible.
You'll have to do something similar as the VBScript example here: http://stackoverflow.com/questions/18390330/call-perl-script-from-vbscript

I'm guessing that should be possible with JavaScript as well.

Geert

orchidLAN

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Call a external perl script from inside EA
« Reply #2 on: January 09, 2016, 03:17:22 am »
Thank you Geert!

Finally I got it by using VBscript and Jscript. I did not find any equivalent command like in Javascript. But because Jscript and Javascript use the same EAConstants library, so it is very easy to link them together.

Here is the code I use in case of any help:

Jscript:
   var oShell;
   oShell = new ActiveXObject ("WScript.Shell");
   oShell.run ( "the route of the '.cmd' file");

VBScript:
   dim oShell
   set oShell = CreateObject ("WScript.Shell")
   oShell.CurrentDirectory = " the Directory want to used"
   oShell.Run "the route of the '.cmd' file"
   set oShell = nothing