Redirecting the console output directly to email message body

Five Stars

Redirecting the console output directly to email message body

I have a requirement of redirecting console output to email. But, the console output needs to be written to the message body of the email. 
I also understand that tjava needs to be used. May I know where must I connect it?
I DO NOT want to write into any file and then read it or attach to an email.
 I want to run this as a .sh job
Please find the below screenshot. I have introduced an error on purpose in the tmysqloutput. 

I also want the job to stop executing and hence, used the tdie. 
Request you to help me achieve this
Thanks in advance


Re: Redirecting the console output directly to email message body

We usually use tLogCatcher to capture the error message and log them into file or database, but it is impossible to output the full stack trace.
We can capture the error message "[font=Verdana, Helvetica, Arial, sans-serif]Exception in component tmysqlsp_1[/font]
[font=Verdana, Helvetica, Arial, sans-serif]com.mysql.jdbc.exception.jdbc.mysqlsyntaxErrorException[/font]" with tLogCatcher component, not the full stack trace.
Did you really need to redirect the full stack trace on console output to email?
Best regards
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: Redirecting the console output directly to email message body

Hi Sabrina,
Thank you for the response.
The error message as shown  by you is enough and the full stack trace would not be needed
Please find below the job design. Inside tjavarow I have globalMap.put("errorCode", input_row.message);
And inside the message body of tsendmail I have "the error message is: "+(String)globalMap.get("errorCode")

This works. I get the error in the body of the email. However, the job does not get killed  and keeps running and sends infinite number of emails. I have to manually kill the job to stop it. The tdie is not killing the job. 

Please let me know where am I going wrong.

Also, in case of Rejects I would want to send an warning email and do not want the job to end. How do I accomplish this?  The rejects go to a database table.



Talend named a Leader.

Get your copy


Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration


Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach