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
I want to use the ErrorCode value on the link task, but I have no luck getting it to work. Is there a way to do this?
I use Command task with this command:
test -f $PMTargetFileDir/fdata.txt; echo $((1/$?))
1) If the file exists $? equals to 0.
2) If the file does not exist $? equals to 1.
So, in 1) $((1/$?)) will cause th error (division by zero). 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 .
Create a command task just before your main session
Link this command task to main session and put link condition as $prevtaskstatus=succeeded
and write below code in Command task
head -2 /testfiledir/test.txt
Command task will fail if file does not exist and succeeds if file exist.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.