Hitachi Vantara Pentaho Community Forums
Results 1 to 12 of 12

Thread: question about passing parameters via command line

  1. #1
    Join Date
    Jul 2010
    Posts
    6

    Default question about passing parameters via command line

    I am sure I am missing something but I don't know what.

    I want to be able to pass in the DB password via the command line.

    I use:
    ./kitchen.sh -file=$UDHOME/bin/ETL/repository/Student_Registration.kjb -paramB_PASS=$DB_PASS

    and in the password field of the database connection I have ${DB_PASS} (I have verified that I typed it in correctly in the .kdb since the password characters are hidden with *'s)

    Is there something more that I need to be doing?

  2. #2
    Join Date
    Mar 2010
    Posts
    159

    Default

    Are you passing the literal password in your command line? $DB_PASS doesn't mean anything special as a parameter value, with that literal example I think you'd try to login with "$DBPASS" as the password. Otherwise I use /param: instead of -param: but things work fine.

  3. #3
    Join Date
    Jul 2010
    Posts
    6

    Default

    No, I want to pass in the value that the shell environment variable holds into kitchen . I have not had any luck using -param. How do I pick up the param variable in a job or transformation? Going with my initial example I have tried to pass in the db password by using -paramB_PASS=$DB_PASS . On the 'inside' I try to use the variable in a transformation by using ${DB_PASS} but I just get the literal string ${DB_PASS}. As if the resolving of that variable failed and then kitchen just went with using ${DB_PASS} literally.

  4. #4
    Join Date
    Mar 2010
    Posts
    159

    Default

    Ahh I understand now... I haven't tried inclusion of shell vars in the command line before.

  5. #5
    Join Date
    Jul 2010
    Posts
    6

    Default

    I have stepped back and looked at the samples provided with the install. I am looking at the samples/jobs/arguments2 example.
    I am expecting that if I invoke the job like so:
    ./kitchen.sh -file=samples/jobs/arguments2/pass_arguments.kjb -param:arg1=test1 -param:arg2=testing -param:arg3=AnotherTest
    that the parameters.txt file will look like this:

    arg1;arg2;arg3
    test1;testing;AnotherTest

    but sadly, it comes out as:

    arg1;arg2;arg3
    ;;

    Is there something that I am missing about how variables work in kettle?

  6. #6
    Join Date
    Nov 1999
    Posts
    9,729

  7. #7
    Join Date
    Jul 2010
    Posts
    6

    Default

    Thanks for the link Matt. However, it doesn't answer the question regarding why the bundled sample "arguments2" doesn't seem to work.
    Since I want to use variables in the manner that arguments2 uses them and the sample won't work, I don't have much of a chance to get my own version working. Unless the sample is malformed in some way. But it seems to be a pretty simple sample so I don't think that is the case.

    Is the proper way for starting up the arguments2 sample like this?

    /kitchen.sh -file=samples/jobs/arguments2/pass_arguments.kjb -param:arg1=test1 -param:arg2=testing -param:arg3=AnotherTest

  8. #8
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Thanks for the reply Glenn. However, you didn't read the content of the "Named Parameters" page.
    One simple requirement is that you specified the named parameters in the job.

    The mentioned page explains how to define named parameters and how to list and set them at runtime.

    The example you are referencing passes *positional* arguments which is not something I would recommend doing these days. It's a possibility and rather simple, be it somewhat confusing:

    Code:
    sh kitchen.sh -file=samples/jobs/arguments2/pass_arguments.kjb test1 testing AnotherTest

    Good luck,

    Matt

  9. #9
    Join Date
    Jul 2010
    Posts
    6

    Default

    I know why you are Chief of Data Integration now! Thanks for the help. That was the nudge that made things click for me.

    If you aren't encouraging the method of parameter passing that is demonstrated in arguments2 it would be a good thing to take that example out. I never saw any reference to that kind of parameter passing.

    jbeal, FYI I was able to pass in an environment variable on the command line. ie pan.sh -file:/blah/something.ktr -paramB_USER=$DB_USER

    Thanks Matt and jbeal for helping out a newbie.

  10. #10
    Join Date
    Mar 2010
    Posts
    159

    Default

    You're welcome gb - and thanks for the info on env var sub working. I never thought about the parameter definition in the job/transform potentially missing, always defined them there first with defaults and then later pumped in external values. Old habits from C, prototype your functions etc. Matt is patient to help because this is an issue that new users miss frequently enough despite the descriptive page. But you're not the only one...

    Regards,
    Jeremy

  11. #11
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    No worries, we devoted "a few" pages on the subject in our upcoming book ;-)

  12. #12
    Join Date
    Jul 2010
    Posts
    6

    Default

    Something just doesn't seem right about passing parameters from command line.

    I name some parameters with values:


    ./kitchen.sh -file=/Users/gbuckholtz/Documents/udmaint/bin/ETL/repository/Student_Registration.kjb -param:FEEDROOT=$UDHOME/bin/ETL/feeds -param:UDHOME=${UDHOME} -listparam

    And I see that kitchen recognizes that I have named parameters based on this output:

    INFO 27-08 14:57:26,309 - Kitchen - Kitchen
    Parameter: DB_HOSTNAME=, default=DEFAULTHOSTNAME : The name of the machine hosting UD database
    Parameter: DB_NAME=, default=DEFAULTDBNAME : The name of the UD database
    Parameter: DB_PASS=, default=DEFAULTDBPASS : The password for the UD user
    Parameter: DB_PORT=, default=DEFAULTDBPORT : The port of the database
    Parameter: DB_TABLESPACE=, default=DEFAULTDBTABLESPACE : in dev this would be udmaint
    Parameter: DB_USER=, default=DEFAULTDBUSER : The user that we are running under
    Parameter: FEEDROOT=/Users/gbuckholtz/Documents/udmaint/bin/ETL/feeds, default=DEFAULTFEEDROOT : The root location were the flat files are found
    Parameter: UDHOME=/Users/gbuckholtz/Documents/udmaint, default=DEFAULTUDHOME : The root of the UD project.



    In the job I have set the parameters:


    But when I try to use them, I get nothing but the default value. This is not what I expected.

    I have a Log step in my job to print out a parameter that I set via command line.

    INFO 27-08 15:19:51,892 - Student_Registration - Starting entry [Log Feed Root]
    INFO 27-08 15:19:51,894 - DEFAULTFEEDROOT - found the feedroot DEFAULTFEEDROOT
    and my UDHOME is DEFAULTUDHOME

    INFO 27-08 15:19:51,895 - Student_Registration - Finished job entry [Log Feed Root] (result=[true])



    What am I doing wrong?
    Last edited by gbuckholtz; 08-27-2010 at 03:25 PM.

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.