Announcement

Collapse
No announcement yet.

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.
    Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
    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.
        Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
        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;
          Mirth 3.8.0 / PostgreSQL 11 / Ubuntu 18.04
          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