Page 1 of 1

trigger job only if file exists

Posted: Mon Dec 08, 2014 5:45 pm
by harryhome
Hi

Job needs to run only if file is present on server. using execute command stage written command as wc -l filepath/filename and then conditions for output link are custom return output = 0 then no file link otherwise is in file output link.

but this logic is not working any suggestion with any other logic in execute command stage?

Posted: Mon Dec 08, 2014 6:28 pm
by chulett
I prefer the UNIX test commands, for example:

test -f filename returns true if the file exists, false otherwise
test -s filename if the file exists and is not empty, false otherwise

Those are my two ways I use quite a bit. Also note that you check the status of the command, not the output.

Posted: Tue Dec 09, 2014 7:23 pm
by ray.wurlod
Why not use a WaitForFile activity in your sequence, with a really short timeout (perhaps 1 second)? The OK trigger fires if the file exists, the Failure trigger fires if the wait times out.

Posted: Wed Dec 10, 2014 10:09 am
by boxtoby
The reply from the command probably needs trim(output, @FM, "A") in a User Variable stage.

Output from commands always has the @FM character appended to the end.

Hope that helps.

Bob.

Posted: Mon Dec 22, 2014 3:07 am
by boolseye
3 ways
1) file watcher job if you have external scheduler like controlm
2) waitfor file activity stage
3) check the count of directory from job and if it is non-zero then trigger the jobs.