Announcement

Collapse

NextGen (Mirth) Connect 3.11.0 Released!

NextGen (Mirth) Connect 3.11.0 is now available as an appliance update and on our GitHub page. This release contains improvements to licensing and the NCPDP data type. It also includes various security fixes, general bug fixes, and improvements to commercial extensions. See the release notes for the complete list of fixes and improvements.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Java Runtime command working in JavaScript Reader source but not preprocessor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java Runtime command working in JavaScript Reader source but not preprocessor

    I want to run a simple Unix command in the Preprocessor of a channel but it's not working. It simply does not run:

    Code:
    java.lang.Runtime.getRuntime().exec("/opt/mirthconnect/mccommand -s /path/script.sh");

    It does, however, work in the JavaScript Reader source connector. Is there anything I need to change to get it to work in the Preprocessor?
    Last edited by Macatouille; 07-30-2020, 06:59 AM.

  • #2
    This seems fine, what is your complete code?

    Code:
    var stuff = java.lang.Runtime.getRuntime().exec("touch /tmp/junk.txt");
    
    return;
    You don't need to set the var... just habit of mine.
    Diridium Technologies, Inc.
    https://diridium.com

    Comment


    • #3
      Originally posted by pacmano View Post
      This seems fine, what is your complete code?

      Code:
      var stuff = java.lang.Runtime.getRuntime().exec("touch /tmp/junk.txt");
      
      return;
      You don't need to set the var... just habit of mine.
      The code I provided was complete - except the path is different. I literally copied and pasted that into the Source and it works. On the preprocessor side I did have return message afterword instead of return so maybe that is worth testing?
      Last edited by Macatouille; 08-03-2020, 06:06 AM.

      Comment


      • #4
        I read post, not pre processor. My bad. I’ll look in a bit.
        Diridium Technologies, Inc.
        https://diridium.com

        Comment


        • #5
          Either option below seems fine... I do mostly the first one and write batch scripts that return something for further review in the engine.

          Two options in the below to call a shell script:


          Code:
          var shell_to_command_line = java.lang.Runtime.getRuntime().exec(["ls", "/tmp"]);
          shell_to_command_line.waitFor();
          var the_command_output = shell_to_command_line.getInputStream();
          $gc('_cmd_output', org.apache.commons.io.IOUtils.toString(the_command _output));
          
          java.lang.Runtime.getRuntime().exec("touch /tmp/junk3.txt");
          
          return message;
          Diridium Technologies, Inc.
          https://diridium.com

          Comment


          • #6
            Macatouille Are you sure you are returning any messages to trigger the pre-processor?

            Comment

            Working...
            X