[resolved] Component to test if FTP folder exist?

Highlighted
One Star

[resolved] Component to test if FTP folder exist?

Hello,
I am looking for a simple way to test if a ftp folder exists.
I have tested with tFTPFileExists and tFTPFileList, but no chance. When folder does not exists a java exception is thrown.
How can I do a such test with Talend?
I am working in TOS 4.1.0M3
Thanks for helping,
Eduard

Accepted Solutions
Highlighted

Re: [resolved] Component to test if FTP folder exist?

Try this way

tJava Code:
context.test = 
((String)globalMap.get("tFTPGet_1_ERROR_MESSAGE")).equals("test: No such file or directory") ? "yes" : "no";

if statements code:
context.test == "yes"
context.test == "no"

As I don't think there is a more soft way, that I know of atleast i may be mistaken

View solution in original post


All Replies
Highlighted

Re: [resolved] Component to test if FTP folder exist?

Take off die on error.
Then it will be:
tFTPGet --on Subjob Failure--> Desired Component
Look at the images below to help you.



If you want it to loop the job again until the Directory exists ask me and I will show you another example.
Regards
Brandon
Highlighted
One Star

Re: [resolved] Component to test if FTP folder exist?

Hi Brandon,
In my very first approach I wanted to do it "more soft" : without raising any exception.
If there isn't any other way I will do it like this, and try to workaround the exception with logging set up.
Many thanks for your help,
Eduard
Highlighted

Re: [resolved] Component to test if FTP folder exist?

Try this way

tJava Code:
context.test = 
((String)globalMap.get("tFTPGet_1_ERROR_MESSAGE")).equals("test: No such file or directory") ? "yes" : "no";

if statements code:
context.test == "yes"
context.test == "no"

As I don't think there is a more soft way, that I know of atleast i may be mistaken

View solution in original post

Highlighted
One Star

Re: [resolved] Component to test if FTP folder exist?

Many thanks for your help Brandon,
your solution is quite good.
If there is no other solution I will set this topic as resolved.
Eduard
Highlighted
Six Stars

Re: [resolved] Component to test if FTP folder exist?

Hi Brandon,

I saw your post and looking for a solution to check if the file exists on ftp server using tftpfileexist. If not it should check again every 1 minute and kick the job once the file is found and send a notification once the process is done and loop back to check for the next file. If the file is not found after certain period it should send a notification and loop again to check if the file is present. How to achieve this? A detail job would be helpful.

Thanks

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog