Command Executor
com.ergotech.vib.manipulators.CommandExecutor
Introduction
This manipulator is used to run a native command on the computer where MIX or the deployed TransSECS software is running. For example, to get a list of image png files in a directory, on Linux run “ls *.png -a -1” and on Windows the equivalent run in cmd /c “dir *.png /b”.
Using in MIStudio
This Bean has two inputs which are used as triggers to run the command in the “command” property. The output of the Command Executor is the result of the command execution, but can be empty if no output is generated. Parameters can be passed to the command as an Array Value Object to the “Argument Input” trigger, where each element of the ArrayValueObject is a {[stringvaluebojects|StringValueObject]] with a parameter.
The Output of this Bean is the text which would be generated if the command were executed in a command shell or terminal.
Run a Simple Command
To get a list of png image files in directory C:\pathtoimages\myimages on Windows, enter this as the “Command”
cmd /c dir C:\pathtoimages\myimages\*.png /b
and connect a Button to the “Trigger” input to test. The output can be displayed in a TextArea on the Design screen and should contain a list of png files in that directory.
In Linux, the Command will be similar, but in this example we change to the images directory then get the list of png files in it:
(cd /home/myname/mypath/images && ls -a -1 *.png)
Running a .sh or .bat
You can use the Command Executor to run a Linux .sh or Windows .bat. Example commands for Linux and Windows are:
./reports/run_report.sh
cmd /c start .\\reports\\run_report.bat
Passing Parameters
An Array Value Object can be constructed (either by script or using a StringToArray, for example) and passed into the “Argument Input” trigger of the CommandExecutor. The AVO will trigger the command set in the “Command” property with the elements of the array on the command line in order that they were added to the AVO.
Configuration
Command: The command to be executed when triggered (either the “Trigger” or the “Argument Input” can be used as a trigger).