Check to see if a 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
jherr22
Premium Member
Premium Member
Posts: 56
Joined: Mon Jan 29, 2007 3:24 pm
Location: Denver
Contact:

Check to see if a file exists

Post by jherr22 »

I have a case where I do not know at runtime if an input file will exist. Is there a way to dynamically test from datastage if a file exists and continue on if it does not exist? I am running a sequence, and if the file does not exist, I do not want the job accessing it to abort, which would cause the sequence to abort. Any thoughts?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You could use the Execute Command stage to do (off the top of my head) a "test -f filename" on the file and then conditionally run the job based on the result. Or perhaps "-s" if you need to check if it exists and is not empty as well.
-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 »

A Routine activity that did the same thing - either with a command or via BASIC statements such as OpenSeq - might be more flexible in terms of logging informative/alert messages. Of course you could also direct a trigger from the Execute Command activity to a logging routine activity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jherr22
Premium Member
Premium Member
Posts: 56
Joined: Mon Jan 29, 2007 3:24 pm
Location: Denver
Contact:

Post by jherr22 »

Thanks for the help - you sent me the answer I was looking for and it works PERFECT!
Post Reply