Invoking a script in a remote server and returning the exit code

One Star

Invoking a script in a remote server and returning the exit code

Do you know if there is any component that invokes a script in a remote server?
For example, I'd like to invoke a C or PHP script in a remote Unix Server using Talend.
The script returns an exit code that indicates success (0) or failure (1).
Is this something I can do through Talend?
Thanks,
Daniel
Employee

Re: Invoking a script in a remote server and returning the exit code

Hi,
tSSH should do it.
HTH,
One Star

Re: Invoking a script in a remote server and returning the exit code

Thanks for the reply. I am now using the tSSH component to run a PHP script in a remote server. The command line I've put in the component is as below.
"php /var/www/html/sample/www/test/crontest.php"
The tSSH successfully ran the script. However, I am still not sure how I can return the exit code so to know if the php script ran successfully or not.
Although I've tried "exit 0", "exit 1", or "exit -1" in the PHP script, it all led to the "Success" message box, not the "Fail" message box.
Am I missing something?



Thank you!!!!
Daniel
Community Manager

Re: Invoking a script in a remote server and returning the exit code

Hello Daniel
tSSH component run actually ok even thought the exit code is 1 or 0 return by php script.
Did you try the global variable: ((Integer)globalMap.get("tSSH_1_EXIT_CODE")). Check the value of this variable when your php script run successfully or not.
tSSH--RunIf(((Integer)globalMap.get("tSSH_1_EXIT_CODE"))==1)-->tMsgBox
|
RunIf(((Integer)globalMap.get("tSSH_1_EXIT_CODE"))==0)-->tMsgBox
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Invoking a script in a remote server and returning the exit code

I appreciate your help Shong. It worked perfectly.

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