Home Forums Development How to invoke perl script from NexJ Studio?

Tagged: ,

Viewing 1 reply thread
  • Author
    Posts
    • #457
      ashutoshashutosh
      Participant

      Hi Team,

      I want to know how we can invoke a perl script from nexJ studio. Is there any method, we can use to do that.

      Regards,
      Ashutosh

      0
    • #459
      Ed ShawEd Shaw
      Keymaster

      The short answer is “yes” you can do this. The important question that goes with it is “why?”. For simplicity and maintainability, we highly recommend looking at your requirements and trying to satisfy them using the model (business model, scheme, persistence, integration, presentation…). BUT – if you have some library that you have invested a great deal of effort in, and need to leverage it… I’ll provide a quick example of how you can call an external program from NexJ. Getting it to work with perl in your environment is another matter, and likely outside the scope of what I can help you with.

      The external program…

      I created a windows batch file called d:/work/doIt.bat that contains the command

      echo "it worked" > "d:\work\doIt.txt"

      So if I run this it will create a file in d:\work\

      In scheme, I can just import some JAVA libraries and run the script from JAVA as follows…
      (import 'java.lang.Runtime)

      (define runtime (java.lang.Runtime 'runtime))

      (define proc (runtime 'exec "d:/work/doIt.bat"))

      (commit)
      Some info on executing perl script from JAVA can be found at:
      http://stackoverflow.com/questions/22448249/executing-perl-script-from-java

      This is one way. Another way would be to write a JAVA class with methods that call your perl script. Then provide the ability to call this JAVA from a Business Model Class’ Event by setting the method property on one of the event’s actions to your JAVA method. I will be posting a detailed article on invoking Java code in studio in the not-too-distant future.

      1
Viewing 1 reply thread
  • You must be logged in to reply to this topic.