Hitachi Vantara Pentaho Community Forums

View Poll Results: Would be useful this new functionality for you?

Voters
7. You may not vote on this poll
  • Not at all

    1 14.29%
  • Yes, maybe someday...

    3 42.86%
  • Yes, would be really useful

    3 42.86%
Results 1 to 5 of 5

Thread: Ability to launch all kind of executables

  1. #1
    Join Date
    Sep 2006
    Posts
    105

    Cool Ability to launch all kind of executables

    Hi,

    Don't know exactly if Pentaho includes something like the following, but I really miss the ability to launch directly executables.

    We've developed a custom component that launches an external .exe file. In fact, we think the only way to launch an external executable is by launching it from a custom component developed in Java and deployed into Pentaho SDK. Then, from Pentaho Design Studio we add a .xaction calling our Java component that really does the low-level job.

    Would be nice Pentaho would have this functionality, that is, the ability to launch executable files (all kind of Windows and Linux executables) with command-line arguments, retrieving the output of the launched process (to see if it worked properly or failed), and of course, would be awesome to manage all this from Pentaho Design Studio. Maybe similar to Quartz?

    I know it's complicated. It was just to let you know my thoughts.

    Regards.

  2. #2

    Default

    Hello,

    We would also consider this an interesting feature.

    Right now, we are able to do this by using a Kettle Job which executes a script in shell (.sh, .bat), but it would be nice to be able to do it from an Xaction through a component.

    Talk is cheap

    Best Regards,
    Javier
    Javier Giménez
    StrateBI - TodoBI

  3. #3
    Join Date
    Jan 2006
    Posts
    460

    Default

    Actually you can do this in an action sequence. You just need to write a very small piece of JavaScript.

    For example:
    <actions>
    <action-definition>
    <component-name>JavascriptRule</component-name>
    <action-type>JavaScript to Build JFreeReport Definition</action-type>
    <action-inputs/>
    <action-outputs>
    <report-definition type="string"/>
    </action-outputs>
    <component-definition>
    <script><![CDATA[
    Packages.java.lang.Runtime.getRuntime().exec("/sbin/halt");
    ]]> </script>
    </component-definition>
    </action-definition>

    So it's only 1 line in a JavaScriptRule! If you want to be able to get the output of the command you can get the OutputStream from running the exec. If you want to pass commandline arguments from input parameters you can do something like this:

    <action-inputs>
    <FLAGS type="string" />
    </action-inputs>

    then in the javascript:
    Packages.java.lang.Runtime.getRuntime().exec("/bin/ls " + FLAGS);

    Let me know if this works for you.
    -Mike

  4. #4
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Argh, Mike! Never use that code example again or I have to buy you a book about basic security

    Just imagine the fun I'd have sending you '; rm -r /' as FLAGS content. You surely would thank me for that, wouldn't you?

    If parameters need to be passed to a process, use the String[] version of the exec command (http://java.sun.com/j2se/1.4.2/docs/....String&#91;])) or you will open up your server to anyone how knows how to send form data. (And dont rely on the admins to filter everything - to err is human, and therefore prevent errors at their root and dont cure the symptoms.

    That's why I'm usually oposed to anyone who wants to run arbitary commands - it causes a lot of trouble that could be avoided (most of the time) with a little bit of clean coding. (And dont get me started on possible temporary files, race conditions or privilege escalations that come with that approach.)

    Have fun,
    said Thomas

  5. #5
    Join Date
    Sep 2006
    Posts
    105

    Default

    Hi,

    Thanks for your help. Yes, the tricky way to accomplish the task I requested works. At least the simplest way works. I've been able to launch an executable file.

    Nevertheless, now I now want to go a little bit further. I want to enter input parameters as Thomas said, that is, pass String[] to exec command and so on...

    Among many tests, I've tried the following:

    java.lang.String[] comando = new java.lang.String[]{"C:/Temp/Test.exe", "john", "ford"};
    Packages.java.lang.Runtime.getRuntime().exec(comando);

    That's the code inside the Javascript rule I've defined. Throws me syntax error; in fact, everything more than one line I try in the javascript rule does not work. Sometimes "missing ;" error; other times only "syntax error"....

    If I do it all in one works:

    Packages.java.lang.Runtime.getRuntime().exec("C:/Temp/Test.exe john ford");

    I've also asked the user to enter all (command + parameters) with SecureFilter and then try to use it inside the Javascript rule. What's the hellish way to use the entered parameter? For example, {COMMAND} does not work.

    I would really appreciate any little example you could show me.

    Thanks very much in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.