简体   繁体   English

检查文件是否存在Informatica工作流程

[英]Check if File Exists Informatica Workflow

I am trying to figure out a way to check if the file exists before running a session. 我试图找出一种在运行会话之前检查文件是否存在的方法。

I currently have a command line task before a sessions that does the following: 我目前在执行以下操作的会话之前有一个命令行任务:

IF EXIST TEST*.TXT EXIT 0 ELSE EXIT 1 如果存在测试* .TXT退出0其他退出1

I want to use the ErrorCode value on the link task, but I have no luck getting it to work. 我想在链接任务上使用ErrorCode值,但是我没有运气让它工作。 Is there a way to do this? 有没有办法做到这一点?

I use Command task with this command: 我将Command任务与此命令配合使用:

test -f $PMTargetFileDir/fdata.txt; 测试-f $ PMTargetFileDir / fdata.txt; echo $((1/$?)) 回声$((1 / $?))

1) If the file exists $? 1)如果文件存在$? equals to 0. 等于0。

2) If the file does not exist $? 2)如果文件不存在$? equals to 1. 等于1。

So, in 1) $((1/$?)) will cause th error (division by zero). 因此,在1)中$((1 / $?))将导致错误(除以零)。 After the Command task you can add two or one of these links: first with the condition $TaskName.PrevTaskStatus=SUCCEEDED , and second with $TaskName.PrevTaskStatus=FAILED . Command任务之后,您可以添加以下两个或一个链接:第一个条件为$ TaskName.PrevTaskStatus = SUCCEEDED ,第二个条件 $ TaskName.PrevTaskStatus = FAILED

Create a command task just before your main session 在主会话之前创建命令任务

Link this command task to main session and put link condition as $prevtaskstatus=succeeded 将此命令任务链接到主会话,并将链接条件设置为$ prevtaskstatus = succeeded

and write below code in Command task 并在Command任务中编写以下代码

head -2 /testfiledir/test.txt 头-2 /testfiledir/test.txt

Command task will fail if file does not exist and succeeds if file exist. 如果文件不存在,命令任务将失败,如果文件存在,则命令任务将成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM