Hitachi Vantara Pentaho Community Forums
Results 1 to 10 of 10

Thread: Question on new step "Execute a process"

  1. #1
    Join Date
    Mar 2006
    Posts
    170

    Talking Question on new step "Execute a process"

    Hi All,

    I am looking for some insight into the brand new step "Execute a process".

    I see in the wiki that it is very much like the "shell" step however I still have some questions :-)

    Descriptions included below:

    Process field ->The field name in the data stream that defines the process to start (shell script / batch file to start). Arguments can also be used.

    Result fieldname ->This field includes the output stream of the process.

    First question:

    Do I need to add a field in my trans so that it can be populated with 'Result fieldname"? I think this field will be added by itself and it will contain a string representation of whatever the exit code was for the process? Is that correct? Or do I need to make sure that a field is available within the row so that it can be set to the string representation of the exit code of the process?

    For a simple example if I wanted to use this to call tnsping:

    1) I would make sure I have at least a row, perhaps gen 1 row
    2) Add a constant named "my_command" that has "$ORACLE_HOME/tnsping my_db_name"
    3) Add a hop to the new "Execute a process" step and set "Process field" = my_command
    and "Result fieldname" = my_exit_code

    I should then be able to test this by adding a dummy step or say a JS step and placing Alert(my_exit_code) and hopefully it will have some return string that tnsping pushed back.

    Is that more or less the way it should flow?

    What happens if the process returns a -1? Will the output string just be "-1"?

    Thanks

    Kent

  2. #2
    Join Date
    Mar 2006
    Posts
    170

    Default

    To follow up I put forth a test like I described above and recieved the following:


    Unexpected conversion error while converting value [result String] to a Number

    result String : couldn't convert String to number
    Unparseable number: "$ORACLE_HOME/bin/tnsping dssdev"

    !
    ERROR 06-07 19:40:38,327 - Calculator.0 - Unexpected error :
    ERROR 06-07 19:40:38,327 - Calculator.0 - org.pentaho.di.core.exception.KettleStepException:
    Error while running the step

    Unexpected conversion error while converting value [result String] to a Number

    result String : couldn't convert String to number
    Unparseable number: "$ORACLE_HOME/bin/tnsping dssdev"



    at org.pentaho.di.trans.steps.calculator.Calculator.processRow(Calculator.java:184)
    at org.pentaho.di.trans.step.BaseStep.runStepThread(BaseStep.java:2889)
    at org.pentaho.di.trans.steps.calculator.Calculator.run(Calculator.java:626)
    Caused by: org.pentaho.di.core.exception.KettleValueException:
    Unexpected conversion error while converting value [result String] to a Number

    result String : couldn't convert String to number
    Unparseable number: "$ORACLE_HOME/bin/tnsping dssdev"


    at org.pentaho.di.core.row.ValueMeta.getNumber(ValueMeta.java:1427)
    at org.pentaho.di.core.row.ValueMeta.convertData(ValueMeta.java:3039)
    at org.pentaho.di.trans.steps.calculator.Calculator.calcFields(Calculator.java:598)
    at org.pentaho.di.trans.steps.calculator.Calculator.processRow(Calculator.java:165)
    ... 2 more
    Caused by: org.pentaho.di.core.exception.KettleValueException:
    result String : couldn't convert String to number
    Unparseable number: "$ORACLE_HOME/bin/tnsping dssdev"

    at org.pentaho.di.core.row.ValueMeta.convertStringToNumber(ValueMeta.java:692)
    at org.pentaho.di.core.row.ValueMeta.getNumber(ValueMeta.java:1380)
    ... 5 more
    Caused by: java.text.ParseException: Unparseable number: "$ORACLE_HOME/bin/tnsping dssdev"
    at java.text.NumberFormat.parse(Unknown Source)
    at org.pentaho.di.core.row.ValueMeta.convertStringToNumber(ValueMeta.java:688)
    ... 6 more


    Thoughts?

    PDI 3.2.0-GA on Linux against Oracle 10g

    Thanks

    Kent

  3. #3
    Join Date
    Mar 2006
    Posts
    170

    Smile Got it to run...

    My issues was I was using the calculator step to append 2 strings. I thought that used to work ... oh well.

    Anyways flipped it so a JS step is puting the strings together and getting the command I want to execute together and that is accepted and does run within the "Execute a Process" step.

    :-)

    Still looking for insight into how the results are returned though.

    Also any thoughts on why when I run a shell serially like

    my_shell

    it works fine however if I issue

    nohup my_shell &

    The overall job exits with no errors however it never kicks off the shells?

    Thanks

    Kent

  4. #4

    Default

    Hi Kent,

    the "Execute process" run an input process string (process/bat file + Arguments) and return the "catched" outputstream (string).
    The output field will be added to the stream by the step and it's not the exit code :-)

    Rgds

    Samatar
    Samatar

  5. #5
    Join Date
    Mar 2006
    Posts
    170

    Default Thanks! Is there any way to run those scripts in the background by chance?

    Again thanks!

    :-)

  6. #6
    Join Date
    Nov 2009
    Posts
    2

    Question Passing Arguments

    Quote Originally Posted by shassan2 View Post
    Hi Kent,

    the "Execute process" run an input process string (process/bat file + Arguments) and return the "catched" outputstream (string).
    The output field will be added to the stream by the step and it's not the exit code :-)

    Rgds

    Samatar
    Anyone has succeeded passing arguments to a .sh file?

    I'm trying to execute a script with the contents of a file as a parameter. It seems the element "Execute a process" can't recognice the whole route with parameters.

    An example of the path generated by my transformation would be:

    Code:
    file:///home/kktuax/kettle-jobs/Pruebas/proceso/proceso.sh 5
    Here's the error it gives:

    Code:
    2009/11/11 18:04:59 - Execute a process.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : Because of an error, this step can't continue: 
    2009/11/11 18:04:59 - Execute a process.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : java.io.IOException: Cannot run program "file:///home/kktuax/kettle-jobs/Pruebas/proceso/proceso.sh": java.io.IOException: error=2, No existe el fichero ó directorio
    2009/11/11 18:04:59 - Execute a process.0 - ERROR (version 3.2.0-GA, build 10572 from 2009-05-12 08.45.26 by buildguy) : Cannot run program "file:///home/kktuax/kettle-jobs/Pruebas/proceso/proceso.sh": java.io.IOException: error=2, No existe el fichero ó directorio
    Here are the files used in the transformation so maybe someone could help: proceso.zip

    Thanks

  7. #7

    Default

    It is accepting the values...but the file "/home/kktuax/kettle-jobs/Pruebas/proceso/proceso.sh" does not exists.

    Are you sure this file exists?

  8. #8
    Join Date
    Nov 2009
    Posts
    2

    Default

    Quote Originally Posted by vlr View Post
    It is accepting the values...but the file "/home/kktuax/kettle-jobs/Pruebas/proceso/proceso.sh" does not exists.

    Are you sure this file exists?
    /home/kktuax/kettle-jobs/Pruebas/proceso/ is the ${Internal.Transformation.Filename.Directory}

    I placed the transformation and proceso.sh in the same directory.

  9. #9

    Default

    how does "execute process" knows when the process is finished ?

  10. #10
    Join Date
    Dec 2013
    Posts
    2

    Default

    Quote Originally Posted by kktuax View Post
    /home/kktuax/kettle-jobs/Pruebas/proceso/ is the ${Internal.Transformation.Filename.Directory}

    I placed the transformation and proceso.sh in the same directory.
    Hi kktuax,

    Could you try with file path which system used to refer the file (without file://)
    for example, I place my shell script file in the same directory as transformation.
    "/home/documents/my_trans/test.sh"
    then I put "/home/documents/my_trans/test.sh" in the content of row and run Execute a process.

    It works for me.

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.