Attachments 0kbs in Notification Activity

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
stivazzi
Participant
Posts: 52
Joined: Tue May 02, 2006 3:53 am

Attachments 0kbs in Notification Activity

Post 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.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post 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?
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
stivazzi
Participant
Posts: 52
Joined: Tue May 02, 2006 3:53 am

Post 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...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I say go for Craig's solution. Build a small routine that checks for file size and uses DSSendMail().
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post 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)
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can also test it from DSSendMailAttachmentTester() routine under utilities in the Built-In section of Routines folder in your repository.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post 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.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
stivazzi
Participant
Posts: 52
Joined: Tue May 02, 2006 3:53 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thank you for confessing your sin, my child. It helps all of us. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

chulett wrote:Thank you for confessing your sin, my child. It helps all of us. :wink:
:lol:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply