
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! I'll give that a try.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"
