Read Falt file and email if row>1
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
Read Falt file and email if row>1
Hi,
I have a reject file in a job, which I need to read at the end of the job or after the job completes and if it has records ,email the same file. I have used unix scripts before but is there a easy way to do it in DS.
Thanks a bunch
I have a reject file in a job, which I need to read at the end of the job or after the job completes and if it has records ,email the same file. I have used unix scripts before but is there a easy way to do it in DS.
Thanks a bunch
-
- Premium Member
- Posts: 503
- Joined: Wed Jun 29, 2005 8:14 am
See whether you can use the routine DSSendMail.
code = DSSendMail("From:me@here\nTo:you@there\nSubject:Hi ya\nAttach:/usr/AFile.txt\nBody:Line1\n%report%")
"From" Mail address of sender
"To" Mail address of recipient
"Subject" Something to put in the subject line of the message
"Server" Name of host through which the mail should be sent.
"Attach" Path of a file to be sent as a mail attachment - multiple paths may be given, separated by commas.
"Body" Something to put in the body of the message.
code = DSSendMail("From:me@here\nTo:you@there\nSubject:Hi ya\nAttach:/usr/AFile.txt\nBody:Line1\n%report%")
"From" Mail address of sender
"To" Mail address of recipient
"Subject" Something to put in the subject line of the message
"Server" Name of host through which the mail should be sent.
"Attach" Path of a file to be sent as a mail attachment - multiple paths may be given, separated by commas.
"Body" Something to put in the body of the message.
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
Hi Vinay,
You need to create a job sequencer and follow the below steps to achieve your requirement.
1) Have an ExecuteCommand stage in the sequencer after your job runs and creates the reject file.
2) Call a shell script in the unix, in which you can useto the get the no of line in the file. Parse the output of this command and get the actual no of lines.
3) In the triggers tab of the ExecuteCommand stage, make expression type as custom and in the expression, put a condition like
3) Next have a NotificationActivity stage and link the output of the ExecuteCommand stage to this and fill the details in this stage and attach your reject file and send an email to the appropriate person.
Thanks,
Naveen
You need to create a job sequencer and follow the below steps to achieve your requirement.
1) Have an ExecuteCommand stage in the sequencer after your job runs and creates the reject file.
2) Call a shell script in the unix, in which you can use
Code: Select all
wc -l <filename>
3) In the triggers tab of the ExecuteCommand stage, make expression type as custom and in the expression, put a condition like
Code: Select all
Execute_Command_0.$CommandOutput > 1
Thanks,
Naveen
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
Hi vinay,
Yes, you need to give the full file path in the below command like
The output from the above command will be something like this
You need to extract the numerical part of the output string, which will give you the number of lines and then use this value for further steps.
Thanks,
Naveen
Yes, you need to give the full file path in the below command like
Code: Select all
wc -l /etl/ascential/datastage/file1.txt
Code: Select all
19 /etl/ascential/datastage/file1.txt
Thanks,
Naveen
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Premium Member
- Posts: 353
- Joined: Wed Apr 06, 2005 8:45 am
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom