Fuego.Util : BatchProgram

The BatchProgram component is used to run non-interactive programs in the server that hosts the Process Execution Engine. The program runs with the same Operating System user as the Engine.

The BatchProgram.run() method runs the program asynchronously. The BatchProgram.runWait() method runs the program synchronously (for example, the call to runWait() blocks until the execution of the program finishes).

The program's exit code is saved in the BatchProgram.errno attribute, and the output in the BatchProgram.output attribute.

Example

In the following example, the Process Execution Engine is running on a Unix machine. The BatchProgram component is used to execute Unix command rsync to do a backup of data files to a remote server:

BatchProgram.commandLine = "rsync -avz /data/images backupserver:/backups/"
BatchProgram.runWait()
exitCode = BatchProgram.errno

if exitCode != 0 then
 throw RuntimeException("Problems synchronizing files. "+
                        "RSync error code="+exitCode)
end