Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
JSey
Creator

How to use an ini file to define file locations etc

Hi

 

I would like to create a job to use an ini file so that upon deployment, I can define certain things like username, password, file folders and names.  I have seen this done before, but I am not sure how to do this in Talend Open Studio.  Any help would be greatly appreciated, thank you very much.

Labels (4)
1 Solution

Accepted Solutions
billimmer
Creator III

Here is something to get you started.

 

tFileExists, to make sure ini file exists, then tFileInputDelimited to read your ini file.  Then connect to a tFilterRow, so you can remove comments that you put in your ini file.  Then connect to tContextLoader.

 

You should still have a context configured for your job, with default values.  So you only need to put overridden values in the ini file.

 

 

 

 

View solution in original post

8 Replies
billimmer
Creator III

Here is something to get you started.

 

tFileExists, to make sure ini file exists, then tFileInputDelimited to read your ini file.  Then connect to a tFilterRow, so you can remove comments that you put in your ini file.  Then connect to tContextLoader.

 

You should still have a context configured for your job, with default values.  So you only need to put overridden values in the ini file.

 

 

 

 

JSey
Creator
Author

Thanks Billimmer!  That worked perfectly!  I do have a follow up question.

 

I need to have the config.ini file somewhere.  How do I set it up so the config.ini file is part of the export when I export a job, and that the script knows how to find the config.ini file where ever it is deployed?

billimmer
Creator III

For myself, I have a "build" folder and a "run" folder.

 

The "build" folder is the target for building my Talend Jobs.  The "run" folder has two things for each job.  An .ini file for each job, and a sub folder for each job.  Both are named the same as the job.  the sub folder holds other sub directories for logs, temp files, file drops, bulk, archiving, etc...  The location of these are defined in the .ini file.

 

Also, most jobs have a "test" context, and and "production" context.  So I would have two .ini files for the job, with the extension of .text or .production.  (I don't actually use .ini).

 

So for deployment, you can send the build, and the "run" environment. 

 

JSey
Creator
Author

From your initial comment:

"tFileExists, to make sure ini file exists, then tFileInputDelimited to read your ini file."

 

Is there a way to make the tFileInputDelimited not hardcoded?  The client would like to move the folder between servers. Smiley Happy

billimmer
Creator III

Use either a system variable such as "user.home" with a tjava

 

context.contextDir = System.getProperty("user.home") + "/talend/run";

 

Or a relative path "../" to get from your build to your run directory?

JSey
Creator
Author

Thanks!  I'll give that a try. Smiley Happy

JSey
Creator
Author

"Or a relative path "../" to get from your build to your run directory?"

 

Sorry, need a bit of clarification.  Let's say I use "../" in my tfileinputdelimited, which directory does the ini file need to be?  Would it be the project direction within the workspace directory?  Thanks.

billimmer
Creator III

it depends on your file structure.  The ../ takes you back one directly level.  So if your "build" directory and "run" directory are:

 

/Talend/build

/Talend/run

 

Then your .bat file is at:

/Talend/build/myjob/myjob_run.bat

And your .ini file is at

/Talend/run/myjob.ini

 

So when you run your job you can get to the .ini with:  

"../run/myjob.ini"