How to setup a Talend job to use command line parameters passed to the .bat file

Four Stars

How to setup a Talend job to use command line parameters passed to the .bat file

Hi all,

 

I've created the context variables below:

 

ContextVariables.png

 

In my tDBInput1's Query field, I have:

"SELECT Instance__c, Instance_Usage_Log_Date__c, userid, teamid
FROM teamcalllogs tcl
INNER JOIN users u ON tcl.userid = u.userid
INNER JOIN teams t ON u.teamid = t.teamid
WHERE Instance_Usage_Log_Date__c > '" + TalendDate.formatDate("yyyy-MM-dd",context.startDate) +
"' AND Instance_Usage_Log_Date__c < '" + TalendDate.formatDate("yyyy-MM-dd",context.endDate) + "' AND Instance__c <> ''
GROUP BY Instance__c, Instance_Usage_Log_Date__c
ORDER BY Instance_Usage_Log_Date__c ASC;"

 

This all seems to be working fine, as it returns the expected number of rows for the context variable default values.

 

Now what I'd like to do is have the possibility of passing the startDate and endDate as command line parameters to the bat file. How can I accomplish this?

 

Right now I'm testing this on a windows environment, but I'll be running it on as a cron job on a unix environment. Will the setup be significantly different?

 

Many thanks in advance,

 

JP

 

 

Fifteen Stars TRF
Fifteen Stars

Re: How to setup a Talend job to use command line parameters passed to the .bat file

You can use --context_param on the command line. For example:

--context_param startDate=whatYouWant --context_param endDate=whatYouWant

You can also have a extenal file to store some of your context variables.

See tContextLoad for details.

You can also have all context variables loaded automatically when the job starts.

See this post where I give the solution.

Hope this helps.


TRF

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads