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.

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.