Hitachi Vantara Pentaho Community Forums
Results 1 to 7 of 7

Thread: Problem reading environment variable

  1. #1

    Default Problem reading environment variable

    Have a strange problem reading environment variables from the transformation. Below is a simple .ktr where iam reading the value of the environment variable and writing it to file. Iam working on windows environment. And it does not pick up the variable value. At the same time i could check the value of the variable from the command prompt. Can any 1 help me with this.

    Regards,
    Raju

    <?xml version="1.0" encoding="UTF-8"?>
    <transformation-steps>
    <steps>
    <step>
    <name>Generate Rows</name>
    <type>RowGenerator</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <fields>
    </fields>
    <limit>10</limit>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>118</xloc>
    <yloc>108</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    <step>
    <name>Java Script Value</name>
    <type>ScriptValueMod</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <compatible>Y</compatible>
    <jsScripts> <jsScript> <jsScript_type>0</jsScript_type>
    <jsScript_name>ScriptValue</jsScript_name>
    <jsScript_script>
    var p1 = getVariable(&quot;KTF&quot;, &quot;&quot;
    &#47;&#47;var v2 = getVariable(&quot;java.io.tmpdir&quot;, &quot;&quot;</jsScript_script>
    </jsScript> </jsScripts> <fields> <field> <name>p1</name>
    <rename>p1</rename>
    <type>String</type>
    <length>-1</length>
    <precision>-1</precision>
    </field> </fields> <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>286</xloc>
    <yloc>108</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    <step>
    <name>Text file output</name>
    <type>TextFileOutput</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <separator>;</separator>
    <enclosure>&quot;</enclosure>
    <enclosure_forced>N</enclosure_forced>
    <header>Y</header>
    <footer>N</footer>
    <format>DOS</format>
    <compression>None</compression>
    <encoding/>
    <endedLine/>
    <file>
    <name>C:\Documents and Settings\raju.shetty\Desktop\file</name>
    <is_command>N</is_command>
    <extention>txt</extention>
    <append>N</append>
    <split>N</split>
    <haspartno>N</haspartno>
    <add_date>N</add_date>
    <add_time>N</add_time>
    <pad>N</pad>
    <fast_dump>N</fast_dump>
    <splitevery>0</splitevery>
    </file>
    <fields>
    </fields>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>441</xloc>
    <yloc>173</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    </steps>
    <order>
    <hop> <from>Generate Rows</from><to>Java Script Value</to><enabled>Y</enabled> </hop>
    <hop> <from>Java Script Value</from><to>Text file output</to><enabled>Y</enabled> </hop>
    </order>
    <notepads>
    </notepads>
    </transformation-steps>

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    It doesn't support reading of environment variables.

    Regards,
    Sven

  3. #3

    Default

    Thanks Sven, as suggested iam setting the variable in the earlier transformation and trying to use the variable in subsequent transformation. Still i could not get the value of the variable.

    Have created an extreamly simple transformation.

    Step 1. Created a Job that has two transformations embedded in it

    - > (a) Set Variable
    - > (b) Get Variable and write to a file.

    When i write to the file, the value is not written to the file. Not sure why...

    Regards,
    Raju

    Job XML
    =============

    <?xml version="1.0" encoding="UTF-8"?>
    <job-jobentries>
    <entry>
    <name>START</name>
    <description>Special entries</description>
    <type>SPECIAL</type>
    <start>Y</start>
    <dummy>N</dummy>
    <repeat>N</repeat>
    <schedulerType>0</schedulerType>
    <intervalSeconds>0</intervalSeconds>
    <intervalMinutes>60</intervalMinutes>
    <hour>12</hour>
    <minutes>0</minutes>
    <weekDay>1</weekDay>
    <DayOfMonth>1</DayOfMonth>
    <parallel>N</parallel>
    <draw>Y</draw>
    <nr>0</nr>
    <xloc>51</xloc>
    <yloc>139</yloc>
    </entry>
    <entry>
    <name>JavaScript Access environment variables</name>
    <description>Transformation</description>
    <type>TRANS</type>
    <filename>file:///F:/SO/KettlePOC/env Variables.ktr</filename>
    <transname/>
    <directory>/</directory>
    <arg_from_previous>N</arg_from_previous>
    <exec_per_row>N</exec_per_row>
    <clear_rows>Y</clear_rows>
    <clear_files>Y</clear_files>
    <set_logfile>N</set_logfile>
    <logfile/>
    <logext/>
    <add_date>N</add_date>
    <add_time>N</add_time>
    <loglevel>Nothing</loglevel>
    <cluster>N</cluster>
    <slave_server_name/>
    <parallel>N</parallel>
    <draw>Y</draw>
    <nr>0</nr>
    <xloc>200</xloc>
    <yloc>139</yloc>
    </entry>
    <entry>
    <name>env Variables 2</name>
    <description>Transformation</description>
    <type>TRANS</type>
    <filename>file:///F:/SO/KettlePOC/env Variables - 2.ktr</filename>
    <transname/>
    <directory>/</directory>
    <arg_from_previous>N</arg_from_previous>
    <exec_per_row>N</exec_per_row>
    <clear_rows>Y</clear_rows>
    <clear_files>Y</clear_files>
    <set_logfile>N</set_logfile>
    <logfile/>
    <logext/>
    <add_date>N</add_date>
    <add_time>N</add_time>
    <loglevel>Nothing</loglevel>
    <cluster>N</cluster>
    <slave_server_name/>
    <parallel>N</parallel>
    <draw>Y</draw>
    <nr>0</nr>
    <xloc>396</xloc>
    <yloc>139</yloc>
    </entry>
    </job-jobentries>


    Transformation 1 XML
    =======================

    <?xml version="1.0" encoding="UTF-8"?>
    <transformation-steps>
    <steps>
    <step>
    <name>Java Script Value</name>
    <type>ScriptValueMod</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <compatible>Y</compatible>
    <jsScripts> <jsScript> <jsScript_type>0</jsScript_type>
    <jsScript_name>ScriptValue</jsScript_name>
    <jsScript_script>
    var ktf = &quot;F:\SO\kettlePOC&quot;;
    //var v2 = getVariable(&quot;java.io.tmpdir&quot;, &quot;&quot;</jsScript_script>
    </jsScript> </jsScripts> <fields> <field> <name>ktf</name>
    <rename>ktf</rename>
    <type>String</type>
    <length>-1</length>
    <precision>-1</precision>
    </field> </fields> <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>267</xloc>
    <yloc>118</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    <step>
    <name>Set Variables</name>
    <type>SetVariable</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <fields>
    <field>
    <field_name>ktf</field_name>
    <variable_name>KTF</variable_name>
    <variable_type>ROOT_JOB</variable_type>
    </field>
    </fields>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>459</xloc>
    <yloc>106</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    </steps>
    <order>
    <hop> <from>Java Script Value</from><to>Set Variables</to><enabled>Y</enabled> </hop>
    </order>
    <notepads>
    </notepads>
    </transformation-steps>


    Transformation 2 XML
    ==============
    <?xml version="1.0" encoding="UTF-8"?>
    <transformation-steps>
    <steps>
    <step>
    <name>A Filter rows</name>
    <type>FilterRows</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <send_true_to/>
    <send_false_to/>
    <compare>
    <condition>
    <negated>N</negated>
    <leftvalue>DB</leftvalue>
    <function>IS NULL</function>
    <rightvalue/>
    <value><name>constant</name><type>String</type><text>A</text><length>-1</length><precision>-1</precision><isnull>N</isnull></value> </condition>
    </compare>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>367</xloc>
    <yloc>196</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    <step>
    <name>B Filter rows</name>
    <type>FilterRows</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <send_true_to/>
    <send_false_to/>
    <compare>
    <condition>
    <negated>N</negated>
    <leftvalue>DB</leftvalue>
    <function>IS NOT NULL</function>
    <rightvalue/>
    <value><name>constant</name><type>String</type><text>B</text><length>-1</length><precision>-1</precision><isnull>N</isnull></value> </condition>
    </compare>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>366</xloc>
    <yloc>306</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    <step>
    <name>Get Variables</name>
    <type>GetVariable</type>
    <description/>
    <distribute>N</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <fields>
    <field>
    <name>DB</name>
    <variable>%%KTF%%</variable>
    </field>
    </fields>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>221</xloc>
    <yloc>249</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    <step>
    <name>Text file output</name>
    <type>TextFileOutput</type>
    <description/>
    <distribute>Y</distribute>
    <copies>1</copies>
    <partitioning>
    <method>none</method>
    <schema_name/>
    </partitioning>
    <separator>;</separator>
    <enclosure>&quot;</enclosure>
    <enclosure_forced>N</enclosure_forced>
    <header>Y</header>
    <footer>N</footer>
    <format>DOS</format>
    <compression>None</compression>
    <encoding/>
    <endedLine/>
    <file>
    <name>C:\Documents and Settings\raju.shetty\Desktop\file</name>
    <is_command>N</is_command>
    <extention>txt</extention>
    <append>N</append>
    <split>N</split>
    <haspartno>N</haspartno>
    <add_date>N</add_date>
    <add_time>N</add_time>
    <pad>N</pad>
    <fast_dump>N</fast_dump>
    <splitevery>0</splitevery>
    </file>
    <fields>
    </fields>
    <cluster_schema/>
    <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
    <xloc>573</xloc>
    <yloc>309</yloc>
    <draw>Y</draw>
    </GUI>
    </step>
    </steps>
    <order>
    <hop> <from>B Filter rows</from><to>Text file output</to><enabled>Y</enabled> </hop>
    <hop> <from>Get Variables</from><to>A Filter rows</to><enabled>Y</enabled> </hop>
    <hop> <from>Get Variables</from><to>B Filter rows</to><enabled>Y</enabled> </hop>
    </order>
    <notepads>
    </notepads>
    </transformation-steps>

  4. #4
    Join Date
    May 2006
    Posts
    4,882

    Default

    Attach your jobs instead of pasting them in... in at least 1 transformation there's an error in the xml itself.

    Regards,
    Sven

  5. #5

    Default

    Attached are the files for the job and transformations.

    Regards,
    Raju
    Attached Files Attached Files

  6. #6
    Join Date
    May 2006
    Posts
    4,882

    Default

    For environment variables.ktr:
    - use a row generator with 1 row to trigger the javascript step... it won't work on itself.
    - use \\ where you use \ in javascript step, or probably better use /

    Regards,
    Sven

  7. #7

    Default

    Hi Sven,

    post those changes, still i dnt get the varialbles in the file. Not sure why :-(

    Regards,
    Raju
    Attached Files Attached Files

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.