Wait for File

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
kittu.raja
Premium Member
Premium Member
Posts: 175
Joined: Tue Oct 14, 2008 1:48 pm

Wait for File

Post by kittu.raja »

Hi,

I have a requirement that the job should wait for 2 hours if the file does not come to our server. The file name comes as TXFile_Date ( everyday the date vaires)

I am using wait for file activity but this is not working. I used TXFile_* and it is working in sequential file stage but it is not working in wait for file stage. Its not able to detect the *. can anyone help me out.

Thanks,
Rajesh Kumar
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

Interesting, never tried this. But, if you couldn't do it the way you are attempting to do, you could always:
1) "ls <filename>*" in a Execute command activity and use the output in the Wait for file activity.
or
2) If it is the current date that the file has, then get that in a User variables activity, build the file name there and use that variable in the Wait for File activity

Hope this helps...
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Vivek,

I will try to explain this more clearly. This is what we do. Whenever the sequence starts, we do a ls with the file pattern. and if the file is out there, we will get the file name. If the file is not there, we need to wait for 2 Hrs before aborting the job.

Here I need to pass the file name to the 'Wait for File' activity. But I have only my file pattern. And Wait for file activity doesnt work with file patterns. That expects the exact file name.

The date in my file name would be a cycle date and there is no way to determine the date before the file comes in. Is there a way to handle this in datastage without a unix script?
Arun
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

Not that I am aware of. If you want a pure DS solution, then you might have to "ls" and check if the file exists, if not do a "SLEEP" and loop back. This is kind of (not exactly) simulating what the wait for file activity does. The easier way would be to have a Unix script.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Use timeout setting on Wait For File to wait for 2 hrs or else capture the return code ( Otherwise) and direct it to a termination activity..
jcthornton
Premium Member
Premium Member
Posts: 79
Joined: Thu Mar 22, 2007 4:58 pm
Location: USA

Post by jcthornton »

An alternative would be to have a branch in your sequencer that it goes to if the file is not found.

An execute command there does a sleep nnn to get you your 2 hours. Then you perform your check for the file again using ls and your file pattern.

Abort if not found, merge the flow back in to the rest of your sequence if it is.
Jack Thornton
----------------
Spectacular achievement is always preceded by spectacular preparation - Robert H. Schuller
vivekgadwal
Premium Member
Premium Member
Posts: 457
Joined: Tue Sep 25, 2007 4:05 pm

Post by vivekgadwal »

jcthornton wrote: An execute command there does a sleep nnn to get you your 2 hours. Then you perform your check for the file again using ls and your file pattern.
Well, he doesn't want to wait for 2 hrs and then check the file. He wants the process to start doing its thing within those two hours if there is a file available, else abort.
Vivek Gadwal

Experience is what you get when you didn't get what you wanted
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Thanks everyone. I do have a unix script with the sleep. But I was just wondering whether we would be able to do it in datastage.
Arun
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The "Wait For File" stage does not support wildcards, so you'll need to "work around" that by building your own mechanism. I've coded this in the past as a shell script that loops / checks / sleeps over the X hour period needed, you can then use an Execute Command stage to run it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
arunkumarmm
Participant
Posts: 246
Joined: Mon Jun 30, 2008 3:22 am
Location: New York
Contact:

Post by arunkumarmm »

Thanks Craig and all. This is what I'm doing now.
Arun
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's also possible to code it as a 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.
Post Reply