Server Routine to check whether the file exist or not

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

Server Routine to check whether the file exist or not

Post by SURA »

Hi All

Need: I need to know whether a file is exist in a specific dir. If exist i need to create a .ok file.

Is there is any way to do or Can try to open the file like below and if the below command is suceed, then i can create a .ok file.

SeqFiles = File Path
OpenSeq SeqFiles: aFileName TO Jname


Please guide me.

Thanks
DS User
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The OpenSeq statement will take its Else clause if the file does not exist.

Note that the file will be open for writing and locked - you will still need a CloseSeq statement once you have performed your test.

You could also call DSExecute to execute a UNIX test -f pathname command (yes, even though you're running on Windows).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
SURA
Premium Member
Premium Member
Posts: 1229
Joined: Sat Jul 14, 2007 5:16 am
Location: Sydney

I will close it

Post by SURA »

Thanks Ray

I will close the file. But is it the only way to find the file? Any other command is there to check?

Regards
DS User
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, and I included it in my response.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A Sequence job with the Wait For File stage could do a simple existence check and (if found) trigger a job / routine / whatever to create your 'ok' file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply