Standard IO Redirection and Event Handler Processes - Script Execution

Script Execution

If an event handler executes a script, standard I/O redirection can be done within the script itself. This method provides a little more flexibility with respect to assigning unique names to files that store captured output. If unique names are needed, logic can be set up within the script to construct the name and to ensure that the file does not already exist.

The following figures illustrate sample scripts that contain logic for generating unique file names.

Bourne Shell Script


UNIX

This sample is a Bourne shell script that uses a combination of environment variables set by the UEM Server, the script's process ID, and the current system date/time in order to construct a unique file name used to store the output of the ls -al command.


Windows Batch File


Windows

This sample is a Windows batch file that uses a combination of environment variables set by the UEM Server and the current system date/time in an attempt to construct a unique file name used to store the output of the dir command. Because multiple instances of this script can be executing at the same time, and a process ID is not available to a Windows batch file, a loop exists to retry the file name construction if a matching file is found.



Note

In both of these examples, the redirection is done at the point at which the process is invoked. If the script itself also generates output that needs to be captured, this file would need to be provided via the event definition's handler options (see Standard IO Redirection and Event Handler Processes - Handler Options.