using of tSCPFileExists

Two Stars

using of tSCPFileExists

Hallo,
I want to use the component tSCPFileExists to check an existing file on a remote server before downloading some other files. I can't find any boolean global var with the result of checking. There are only the global var for Error_Message, Filename and Status. How can I use this component?
Two Stars

Re: using of tSCPFileExists

Hallo,
I am hoping that there is someone in this forum who can help me and has the resolution for the problem.
I use TIS 4.2.1.
When I use the component "tFileExist" I can use the boolean global variable "tFileExist_n_EXISTS" with the result of the check in an IF-Link to other components. This is very easy.
But, when I use "tSCPFileExists" to check files on a remote server i can't find a global boolean variable like "tSCPFileExist_n_EXISTS" with the result of the check. I only see the global variables for Error_Message, Filename and Status.
What i have to do to get the result of the check?
Thanks.
One Star

Re: using of tSCPFileExists

Hi,
I think you have a point here. Both components perform a similar action, but return the result in a different way.
tFileExists uses the following code to set tFileExists_n_EXISTS, which results in a boolean:
if (!file_<%=cid%>.exists()) {
globalMap.put("<%=cid %>_EXISTS",false);
}else{
globalMap.put("<%=cid %>_EXISTS",true);
}

(source: <Talendfolder>/plugins/org.talend.designer.components.localprovider_<tal_version>/components/tFileExists/tFileExists_main.javajet)
while tSCPFileExists uses the following code to set tSCPFileExists_n_STATUS, which is a String:
if(("").equals(stringStderr_<%=cid %>.toString()) || stringStderr_<%=cid %>.toString() == null){
globalMap.put("<%=cid %>_STATUS", "File exists.");
}else{
globalMap.put("<%=cid %>_STATUS", stringStderr_<%=cid %>.toString());
}

(source: <Talendfolder>/plugins/org.talend.designer.components.localprovider_<tal_version>/components/tSCPFileExists/tSCPFileExists_main.javajet)
To use the tSCPFileExists component you should probably use the following syntax: ((String)globalMap.get("tSCPFileExists_1_STATUS")).equals("File exists.")
Hope this helps.
Regards,
Arno
Two Stars

Re: using of tSCPFileExists

Hi Arno,
thanks for your help.
Now I use following syntax in an If-Connection: ((String)globalMap.get("tSCPFileExists_1_STATUS")) == ("File exists.")
and so it works.
Many regards,
Detlef
One Star

Re: using of tSCPFileExists

Hi Detlef,
This might indeed work, however, I suggest you use the syntax with the equals method as in my sample: ((String)globalMap.get("tSCPFileExists_1_STATUS")).equals("File exists.")
The syntax for negation would be: !((String)globalMap.get("tSCPFileExists_1_STATUS")).equals("File exists.")
These result in a boolean, equal to your result, but using == for string comparison in Java is discouraged, as far as I know (I'm not a java programmer myself).
Any way, glad I could help you out!
Regards,
Arno