OL Learn

How to Get Watch.ExecuteExternalProgram() value?

I used to plug-in ‘External Program’ that can get value when external program print.

Now, I want to get the blue frame value,

How can I get print value using 'Script - Watch.ExecuteExternalProgram() ?

I would recommend to use the External Program Workflow plugin instead, in case you would like to access the output of executing the external program from within a Run Script Workflow plugin. The reason why I recommend this is because executing the function Watch.ExecuteExternalProgram doesn’t return a value at the moment and the External Program Workflow plugin has the option to assign the output to a Workflow variable (the drop-down menu “Store the program output in variable”). After that you can access this Workflow variable from within a Run Script Workflow plugin by making use of the following JavaScript code, for example:

var printValue = Watch.GetVariable("printValue");

Watch.Log("printValue: " + printValue, 3);

The printValue variable will contain the program’s exit code, an integer that is returned by the program upon exit. The meaning is program-dependent, but most console programs will use 0 to indicate success and other non-zero values to indicate the reason for the failure.

If you want to retrieve the output of the program, that is not possible from this script function. As Marten mentioned, the Run External Program plugin will allow you to capture the exit code and the output.

@Marten @fortiny
I know the ‘Watch.ExternalProgram()’ can’t retrieve the output of the program.
I use External Program Workflow plugin to retrieve the output of the program.

like

But I think it not the simple to maintain workflow.
I will keep find the best to maintain way.

Thanks, all !!

1 Like