'Talend Run If Trigger in tSystem component
Im trying to do some if-else statement in talend using tSystem and perform other tasks based on the output. E.g below is the code to check the file exists or not.
My python code in tSystem:
def check_file_exist(dir):
if os.path.exists(dir):
return 0
else:
return 1
How would it be possible the check if the output from tSystem equals a specific String? For instance, if output return value 0 then do task A, if output return 1 then do task B.
I've tried->
Set Talend pipeline to:
Set Run If component code to:
((Integer)globalMap.get("tSystem_6_EXIT_VALUE"))==0 #file exists ((Integer)globalMap.get("tSystem_6_EXIT_VALUE"))==1 #file not exists
However, the result for both Run-if is same where it only detects the return value 0. E.g in image below, it should give the output "file not exists" as return code 1 is for the file is not exists:
How to make sure the Run-If statement in talend capture the output in tSystem component and direct to next task based on the output condition?
Solution 1:[1]
- I suggest you use a return code in your script, and then check on the value using something like
((Integer)globalMap.get("tSystem_n_EXIT_VALUE")) - I'am not sure what you mean with 2 conditions in parallel, but you could include your 2 conditions in your script
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mat777 |


