File Exists in Directory

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

edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

File Exists in Directory

Post by edward_m »

All,

I want to run the job if the source file exists in directory..if not i want to send an email notifiation to users says source file not exists..
How to check whether file exists in directory..if so run the job else email notification.I am calling this job in sequencer.
Please throw some light on this..
Thanks in advance..
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

Is the sorce filename same all the time ?
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Check if you can use Wait_For_File_Activity in your sequence.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

If its same hardcore it in parameter in job properties and then select the before jobsubroutine "DSwaitfofile".

Add this job in seqencer with Email notificaiton activity.
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

No..The file lands in directory with filename+date ..in before job subroutine i am converting that to fixed name and pass it to job.

Thanks in advance..
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

Ok then I guess you should do everything in Shell script itself.
first check the filename if it exists continue else send email.
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

As i mentioned my DS is on Windows..Is there any code in DOS to check the file exists in directory or not..

Thanks in advance..
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

something like

Code: Select all


x=filename
a=$x + `date`.txt
b=ls -l

if [$a -eq $b];
then 
continue
else
UtilitytoAbort("File does not exist")
fi
use this job with email notification activitiy in a seq
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

Sorry my bad. Something like this but check before doing as I am not sure:

Code: Select all


IF EXITS FILENAME
continue
else
UtilitytoAbort("No File")
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Write a routine that tries to rename the file. If the file is not there (rename was unsuccessful) and returns a non zero return code. If its there, it returns 0 as return code. Call this routine in routine activity in a sequence job and check for its return code. If 0, run the job else send out email using Notification Activity.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

Thanks DSGuru..Could you please throw the code for this routine..

Thanks in advance..
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

How are you currently renaming the file? Just pass that command in DSExecute() in a routine and check the ReturnCode and pass it back.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

DSGuru,

I tried with the following code in the routine its giving error

Code: Select all

Call DSEXECUTE("DOS","copy E:\*.*/a E:srcpos.txt/a",output,SystemReturnCode)
Ans = SystemReturnCode
.

Please advise..
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Replace DOS with NT.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
edward_m
Charter Member
Charter Member
Posts: 257
Joined: Fri Jun 24, 2005 9:34 am
Location: Philadelphia,PA

Post by edward_m »

I did..when i test the output says <<ERROR>>
Program "DSU.FileExists": Line 2, Unable to open the operating system file "DSU_BP.O/DSEXECUTE".
[ENOENT] No such file or directory
Program "DSU.FileExists": Line 2, Unable to load file "DSEXECUTE".
Program "DSU.FileExists": Line 2, Unable to load subroutine.
Thanks in advance..
Post Reply