One Star

Running jobs on other machines - how to work with file paths?

Hi,
I am often reading from (and writing to) CSV and Excel files in my jobs. What is the best practise for file paths when moving jobs around on different machines? If the path is omitted and I just write a file name, what is the current directory when Talend is running?
Thanks.
5 REPLIES
One Star

Re: Running jobs on other machines - how to work with file paths?

Anyone have any input? I need to finish this project on Friday this week. Any help on how to locate the current working directory of the autonomous job is very much appreciated.
Is it enough to omit any path and just refer to "File.CSV" - in that case where should it be located when executing from within the Talend GUI?
One Star

Re: Running jobs on other machines - how to work with file paths?

Create a toplevel PROJECT_DIR or DATA_DIR context variable and have your jobs pull files from both in deployment and the GUI. This way a job (exported Talend job) can pull from > 1 source if needed. The variable also obviates the need for changing into a working directory in a scheduling script and will encourage a separation of data and code that can make upgrades, patches, and deployments easier.
This is a link to a video on using context variables.
http://bekwam.blogspot.com/2011/01/tutorial-deployment-with-talend-open.html
-Carl
One Star

Re: Running jobs on other machines - how to work with file paths?

Thank you, however this may not be exactly what I wondered, as my problem is mainly to do with moving the exported job to a random computer. At the moment it seems I have been able to solve that by using network drive (UNC) paths for all files.
If there was a way to say "two levels up from the directory I started executing in" then that would be very useful. Do you think I could solve this with some magic in the BAT file?
One Star

Re: Running jobs on other machines - how to work with file paths?

Maybe you can make use of these to form the path you want. Set this in a tJava or tJavaRow or tsetGlobal component
 globalMap.put("HOME_DIR", System.getProperty("user.home"));
globalMap.put("WORKING_DIR", System.getProperty("user.dir"));
Seven Stars

Re: Running jobs on other machines - how to work with file paths?

Can you not just use relational directory references in your components e.g. ../../filename.ext for two levels up?