How to call .sh file from Talend

Five Stars

How to call .sh file from Talend

Hello All,

 

I have a requirement to call shell script(.sh file) in my talend job?

I'm using windows operating system and .sh file was placed on my windows desktop, I have to call .sh file in talend and pass the output to target

can any one tell me how can we achieve this requirement?

 

Regards,

Bharath

 

 

Highlighted
Moderator

Re: How to call .sh file from Talend

Hello,

Here is a tSystem component in talend which calls other system processing commands, already up and running in a larger Job.

Best regards

Sabrina

--
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: How to call .sh file from Talend

Hello Sabrina,

 

Thanks for your response!!

 

Could you please provide me some in-sights how shall i call .sh script in tsystem component?

 

For Ex:  Test.sh

------------------------------------

#!/bin/bash -e
indate=$1
opDate=$(date "--date=$indate -1 day")
return opDate

---------------------------------

Above is the .sh file(Test.sh) which was placed on my windows box and talend is in same machine.

I'm not sure how can i get output from Talend?

 

Regards,

Bharath

Six Stars

Re: How to call .sh file from Talend

If you want to run your sh command from your windows box to linux system then you can use tSSH component.

 

You can create that sh file in a context variable and put it into the 'command' text area.

if you are planning to run this job on the linux server then you can tSystem component

Four Stars

Re: How to call .sh file from Talend

Hi ,

 

This is Roopesh , even i am facing some challenge where i have to run .sh file if one of my sub job is failed .

1.Your response above :-If you want to run your sh command from your windows box to linux system then you can use tSSH component. 

You can create that sh file in a context variable and put it into the 'command' text area.

<Roopesh> Can you please share the sample job design and possible set up to be done in command text area , how to put it and what all possible config set up to be done as an example ?

 

2.if you are planning to run this job on the linux server then you can tSystem component

<Roopesh> echo -e \t"Upstream system is down\n\n" | sendmail rupesh.ramrao08@gmail.com , trying to execute the command but not finding the right syntax to be used when we run the job through talend tsystem component.

Please help me with your response on both the components usuage.

 

Thanks

 

Regards,

Roopesh

Four Stars

Re: How to call .sh file from Talend

Hello Sabrina,

 

Please let me know your suggestion / input on the concern which i highlighted.

Awaiting your response.

Sincere thanks..

 

Br

Roopesh

Employee

Re: How to call .sh file from Talend

Hi Roopesh,

 

    For your first query about tSSH, did you check the sample scenario mentioned in the help document?

 

https://help.talend.com/reader/mjoDghHoMPI0yuyZ83a13Q/sTcsNIL7HpmTR~owUepIAA

 

    If you are providing the fully qualified path for your .sh file and if your .sh file is having execute permission, then it should work fine like the sample shell commands.

 

Regarding your second question, I am wondering why you are using tSystem to send mail. Talend is having preconfigured component called tSendMail to end emails with attachments. Could you please use them rather than trying to do everything directly through shell scripts?

 

https://help.talend.com/reader/mjoDghHoMPI0yuyZ83a13Q/Ayp5ah3zMhy2MqXCu4g_Xg

 

If you are just doing all your functionalities by shell scripts directly, you are actually not utilizing the true power of Talend. So please use the components provided by Talend for functionalities like email transmission as it will give you more graphical interface about your overall flow.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Four Stars

Re: How to call .sh file from Talend

Hello Nikhil Thampi,

 

Thanks for your response!

First option i think this would work fine in linux machine but i am using windows machine and i tried using the same but couldn't succeed hence i requested for sample job design how it works and how it should be built) ?

And, yes i have gone through this link ,but it dint suite for my requirement.

https://help.talend.com/reader/mjoDghHoMPI0yuyZ83a13Q/sTcsNIL7HpmTR~owUepIAA.

 

Second option ,yes we can use tsendMail component but in my project local mailers are installed in server and hostname are $outbound_proxy on port number =25 however having these smtp server details aren't shared with us since vendor requires mail to be sent to local mailer installed in server (/usr/sbin/sendmail) instead of smtp server. 

please let me know your response on this regard.

Thanks in advance.

Employee

Re: How to call .sh file from Talend

Ok. In this case, stick to tSystem command to run the commands. 

 

When you are using the tSystem command, what is the issue you are getting? Could you please share some screenshots so that we will get a better understanding of your job?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

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

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch