Launching processes in distributed machines is really well-implemented as a STAF service and also receives special treatment in the companion STAX execution engine. Process management is always a thorny discipline, dealing with process output, error codes, deciding whether or not to wait until they are done, and many other concerns.
I compiled a personal list of STAF/STAX options in launching new processes that always trick newcomers to the tool.
Waiting for a process launched through STAF
Running a command on any given machine running the STAF process is as simple as executing “staf
What often derails people are the default launch settings, which instructs STAF to launch the process **asynchronously* and moving on, often breaking follow on commands that depend on the results of the first. If you must wait until the process completes its execution, you need to use the “WAIT” flag.
The next relevant flag is “SAMECONSOLE”, which prevents STAX from launching a new console (default behavior on Windows) . For most runs of unattended commands, SAMECONSOLE is your option of choice.
The last important flags are the ones indicating that you want STAF to collect the command results, namely RETURNSTDERR and RETURNSTDOUT, as follows:
Results from asynchronous launches
If you really must run a command asynchronously, you need to store the command handle returned by STAF and query its results later on.
Launching the same process using the STAX engine requires more effort, which is understandable since STAX is a more sophisticated execution engine with support for programmatic constructs.
One of the most important observations about the
While observing the results in the Job monitor, we will see:
'local' 'dir \\tmp' "Result code: %i " % STAXResult "Result data: %s " % STAXResult
As usual, the excellent user guides shipped with both STAF and STAX are the most comprehensive material for learning about the intricacies of launching remote processes and manipulating their results. I just missed a short guide like the one above showing the STAF / STAX equivalence side-by-side.