Page 1 of 1

Wait for File

Posted: Wed Oct 20, 2010 12:30 pm
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,

Posted: Wed Oct 20, 2010 12:59 pm
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...

Posted: Wed Oct 20, 2010 1:08 pm
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?

Posted: Wed Oct 20, 2010 1:17 pm
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.

Posted: Wed Oct 20, 2010 1:23 pm
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..

Posted: Wed Oct 20, 2010 1:23 pm
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.

Posted: Wed Oct 20, 2010 1:29 pm
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.

Posted: Wed Oct 20, 2010 1:32 pm
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.

Posted: Wed Oct 20, 2010 1:33 pm
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.

Posted: Wed Oct 20, 2010 2:50 pm
by arunkumarmm
Thanks Craig and all. This is what I'm doing now.

Posted: Wed Oct 20, 2010 3:16 pm
by ray.wurlod
It's also possible to code it as a Routine activity.