trigger job only if file exists

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
harryhome
Participant
Posts: 112
Joined: Wed Oct 18, 2006 7:10 am

trigger job only if file exists

Post 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?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
boxtoby
Premium Member
Premium Member
Posts: 138
Joined: Mon Mar 13, 2006 5:11 pm
Location: UK

Post 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.
Bob Oxtoby
boolseye
Participant
Posts: 18
Joined: Mon Jul 15, 2013 4:01 am

Post 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.
-----------------
Thanks
Post Reply