Execute OS Command

The tool “Execute OS Command” can schedule commands on the local operating system. Those commands must be specified by using input parameters. Several input parameters are concatenated to a single command string using the input parameter separator attribute as the delimiter.

If a program or a batch file was called by the OS Command, AWM can parse its return values, as long as they obey certain syntax rules:

Syntax Description Example
ReturnCode: <returncode> Return code of the tool (default: 0) ReturnCode: 12
Message: <message> Tool message to be displayed in a dialog box (optional) Message: File %1 was not found!
LogMessage: <message> Log messages are displayed in the Eclipse Error Log view after the tool is executed. (optional) LogMessage: Creating file “%filename%”…
OutParm: <parameters> Output parameters of the tool which must be returned at the very end. Output parameters are optional, but the number of parameters must match with the modeled output parameters. In addition the parameter separator must match with the separator defined in the AWM tool descriptor. OutParm: value1 value2

The return code indicates whether the called program or batch file executes successfully or ends with warnings or errors. If the return code is higher than 0, a message is returned. If the return code is higher than the maximum allowed return code an error dialog box appears displaying the tool messages, and the action in which the tool executes is aborted. See Application Options for more information.

Messages returned by the OS command are always displayed in a dialog box in the client after the action is executed. As long as the return code is lower than the maximum allowed return code, returned messages from all tools are collected and displayed after the action is finished. Output parameters must be returned at the very end.

Note: Microsoft Windows batch files automatically "echo" every statement, which can cause problems when returning output parameters. Micro Focus strongly recommends you disable statement echoing by using the "@echo off" statement in the batch file.
This example shows a Windows batch file that returns a message, return code and an output parameter:
@echo off 
… 
echo ReturnCode: 4 
echo Message: No customers found for the given filter %1. 
echo OutParm: %~dp0customers.txt 
This example shows a UNIX shell script that returns a message, return code and an output parameter:
…
echo "ReturnCode: 4"
echo "Message: No customers found for the given filter $1." 
echo "OutParm: /etc/dp0customers.txt"