Hybrid Integration 10.1 | Integrating On-Premises Applications | Integration Server Built-In Services | Utils Folder | pub.utils:executeOSCommand
 
pub.utils:executeOSCommand
WmPublic. Executes an operating system command such as dir in Windows or ls in UNIX.
Caution: Use the pub.utils:executeOSCommand service with extreme caution; the commands can affect the production systems where Integration Server is running.
Parameter Settings for OSCommands.cnf file
The OSCommands.cnf configuration file in the Integration Server_directory \instances\instance_name\packages\WmPublic\config directory contains parameters that Integration Server uses to provide validation checks to make the pub.utils:executeOSCommand service secure.
Note: If you make any changes to the OSCommands.cnf, you must reload the WmPublic package or restart Integration Server for the changes to take effect.
For security reasons, the pub.utils:executeOSCommand service checks the input command parameter against the list of allowedOSCommands in the OSCommands.cnf file. The service also checks the input workingDirectory parameter against the list of allowedWorkingDirectories. If the input command or directory is not on the allowed list, the service throws an exception.
Parameter Settings
The following table shows the parameter settings for the OSCommands.cnf file:
Parameter
Description
allowedOSCommands
List of commands that can be executed using the pub.utils.executeOSCommand service. You can specify commands and command parameters. If you specify a command (example, ps), Integration Server will run any command parameter with that command (such as ps -ef or ps -aux). If you specify a particular command parameter (example, ps -ef) Integration Server will run only that command parameter, not any other parameter associated with the command (such as ps -aux).
allowedWorkingDirectories
List of directories where the allowed commands can be executed.
When modifying the parameters in the OSCommands.cnf file, keep the following points in mind:
*Use semicolon (;) as the delimiter for the allowedOSCommands and allowedWorkingDirectories parameters.
*If a command name or working directory has a semicolon (;), use backslashes (\\) before the semicolon while specifying the allowed paths.
For example, if the allowed command is cmd.exe /c c:/temp/ab;c.txt, specify it as cmd.exe /c c:/temp/ab\\;c.txt when specifying it as a parameter for the OSCommands.cnf file.
Input Parameters
command
String Command to be executed on the target operating system. You can include command parameters only if the command parameters do not contain spaces.
Important: You must use arguments to specify all of the command parameters if any one of the parameters contains spaces.
arguments
String List Optional. All of the command parameters for the command. Add one element to the parameter for each command parameter that you specify.
environment
String List Optional. An array of strings of environment variable settings in the name=value format. Set the value to null if you want the service to use the environment of the current process as the environment for its subprocesses.
workingDirectory
String List Optional. The working directory from which the command is to be executed. Set the value to null if you want the service to use the working directory of the current process as the working directory of its subprocesses.
Output Parameters
status
String The exit value of the executed command. The value 0 (zero) indicates normal termination.
outputMessage
String Output of the executed command.
errorMessage
String Errors that occurred during command execution.
Usage Notes
To execute the dir command on Windows XP using the pub.utils:executeOSCommand, the command parameter is passed as cmd.exe /c dir and the working directory parameter is passed as c:/temp. The outputMessage parameter will contain the files of c:/temp directory.

Copyright © 2015- 2017 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.