Page 1 of 1

Attachments 0kbs in Notification Activity

Posted: Tue Jan 23, 2007 10:46 am
by stivazzi
Hi everybody...
i have a problem with DS..
i create log error files as #path#/#RoutineActivity.$ReturnValue#_error.log... so, as you understand, log names are dynamic every run of the job... then i go back to my sequence and send notification mail with these files attached. But, if these files, even if created, are empty (0kb), a mail arrives with
"WARNING - MISSING ATTACHMENT: Cannot open attachment file " + resolvedFileCompletePath
Is there a way to attach in any case, or better, to write an expression which could say something like "if files are empty, do not attach"?
Remember that sometimes i can create 10 different files, 8empty and 2 full, and no one will be attached..

Hope my problem is clear...

Thank you
A.

Posted: Tue Jan 23, 2007 11:59 am
by narasimha
A workaround -
Check if the file is empty or not by writing a script.
Based on the results, pass the output to two seperate output links which each end in Notification Activity
First Notification Activity you use the attach file option (for files size greater than 0)
Second Notification Activity you dont use the attach file option (for files size 0)
Makes sense?

Posted: Wed Jan 24, 2007 2:17 am
by stivazzi
your answer would make sense, but still i got 2 doubts:
1- how to write a script? i am quite new in DS, not so able in writing scripts... any help would be appreciated
2 - and.. if i have 8empty files and 2 full? the error comes again... i should check for any file if could be attached...

Posted: Wed Jan 24, 2007 8:17 am
by chulett
stivazzi wrote:your answer would make sense, but still i got 2 doubts:
1- how to write a script? i am quite new in DS, not so able in writing scripts... any help would be appreciated
This is not a DataStage task. A UNIX script would be akin to a Windows 'bat' or batch file, something that runs a series of commands. There should be someone where you work who could create or help you create a simple korn shell script to get your feet wet. Then we can help you work it into your job.
stivazzi also wrote:2 - and.. if i have 8empty files and 2 full? the error comes again... i should check for any file if could be attached...
This confuses me... you can only attach one file per Notification Activity. Or does your job design have 10 of them in it?

Never mind, it does say 'Attachments' (plural) and supports a comma delimited list of filenames. That's going to make this very tricky as you would need to build a list of just the non-zero byte files for this to work, it sounds like. Never had a need to send more than one, hmmm...

You'll probably need to 'roll your own' custom routine to check file sizes and build a list of appropriate filenames. Then call the DSSendMail routine from there. Either that or have whatever job creates these files also zip them into a single archive, empties and all - then attach that single file via the Notification Activity stage. Me, I'd go for that solution.

Posted: Wed Jan 24, 2007 8:27 am
by DSguru2B
I say go for Craig's solution. Build a small routine that checks for file size and uses DSSendMail().

Posted: Wed Jan 24, 2007 8:36 am
by chulett
For someone 'quite new to DS' I'd suggest the zip route. Far easier to accomplish... assuming they have a UNIX zip flavor out there.

Posted: Wed Jan 24, 2007 10:13 am
by narasimha
AFAIK the error message you are getting is not because your file is empty.
It is because the Notification Activity sequence is not able to find the specified file.
Check if the file exists before you are attaching it to the Notification Activity sequence.
Even better try and hard code the filename with the path and check if you get the same error (For both empty and Non-empty files, even if the file is empty you shoud not be getting such errors)

Posted: Wed Jan 24, 2007 10:24 am
by DSguru2B
You can also test it from DSSendMailAttachmentTester() routine under utilities in the Built-In section of Routines folder in your repository.

Posted: Wed Jan 24, 2007 10:26 am
by narasimha
In fact I just made a quick test myself. The Notification Activity sequence not finding the the file to attach gives a similar error. It has nothing to do with the attachment file being empty.

Posted: Thu Jan 25, 2007 2:35 am
by stivazzi
my mistake, my mistake, my enormous stupid mistake!!!!!!

FOR NEWBIES: DO NOT PUT SPACES BETWEEN ATTACHMENTS LIST :
"attachA,attachB" not "attachA, attachB"!!!!

sorry :)
A.

Posted: Thu Jan 25, 2007 7:17 am
by chulett
Thank you for confessing your sin, my child. It helps all of us. :wink:

Posted: Thu Jan 25, 2007 8:17 am
by DSguru2B
chulett wrote:Thank you for confessing your sin, my child. It helps all of us. :wink:
:lol: