Forum Discussion

andre_mangatal's avatar
andre_mangatal
New Contributor
7 years ago

Snap To Call An EXE or BAT batch File On Another Server

Good day Snaplogic Community,

I am trying to run a .BAT batch file or an EXE file on a different server but on the same network as out groundplex. Is there a Snap that I can use or another method of doing this in a pipeline?

Thank you very much in advance!

Best regards
Andre

5 Replies

  • cstewart's avatar
    cstewart
    Former Employee

    On a Groundplex you should be able to use the Script Snap to execute a command line, and in that invoke any OS command. If the Operating system supports remote execution of commands, then you should be able to achieve your task.

    • andre_mangatal's avatar
      andre_mangatal
      New Contributor

      Hi CStewart

      Do you know the exact commands or can guide me to an online resource to execute a command line in javascript? I was trying to edit the default code in the script snap.

      var impl = {
      /*
      * These variables (input, output, error, log) are defined by the
      * ExecuteScript snap when evaluating this script.
      */
      input : input,
      output : output,
      error : error,
      log : log,

      /**
       * The "execute()" method is called once when the pipeline is started
       * and allowed to process its inputs or just send data to its outputs.
       *
       * Exceptions are automatically caught and sent to the error view.
       */
      execute : function () {
         this.log.info("Executing Transform Script");
         
         **var wshShell = new ActiveXObject("WScript.Shell");**
      

      wshShell.Run(“D:\dir\user.bat”);
      while (this.input.hasNext()) {
      try{
      // Read the next document, wrap it in a map and write out the wrapper
      var doc = this.input.next();
      var wrapper = new java.util.HashMap();
      wrapper.put(“original”, doc);
      this.output.write(doc, wrapper);
      this.log.info(“Transform Script finished”);

              }
              catch(err) {
                  var wrapper = new java.util.HashMap();
                  wrapper.put("errorMsg", err);
                  this.log.error(err);
                  this.error.write(wrapper);
              }
          }
      }
      

      };

  • Kumargb's avatar
    Kumargb
    New Contributor

    Hi Andre,
    Are you able to resolve this problem. Could you please share the script snap script?