Executing a Script for a Triggered Event Occurrence in Windows
In this example, a demand-driven UEM Server installed on a UNIX machine will watch for the creation of a file called uemtest.dat. Since no path is specified, it will look for this file in the user's home directory.
A relative inactive date / time is used to instruct the UEM Server to monitor the event for 10 minutes. If the file is detected and completes within that time, the event occurrence will be set to the triggered state. The script statements contained within the local file C:\UEMScripts\h_001.txt
then will be written to a temporary script file on uemhost and executed by UEM Server.
The value specified by the -handler_opts option is appended to the command line constructed by UEM to execute the temporary script file. This will cause the values parm1, parm2, and parm3 to be passed to the script. Any output generated by the script will be written to a file in the UEM Server working directory called uemtest.log.
If the file is detected, but does not complete before the inactive time elapses, the event occurrence will be set to a rejected state. Since no event handler information is provided for a rejected occurrence, no further action will be taken by the UEM Server.
If the UEM Server does not detect the presence of uemtest.dat before the inactive time elapses, the event will be set to an expired state. Again, because no handler information is given for this state, no further action will be taken by the UEM Server.
uem -host uemhost -event_type file -filespec uemtest.dat -inact_date_time +10 -userid uemuser -pwd uemusers_password -triggered -script C:\UEMScripts\h_001.txt -handler_opts "parm1 parm2 parm3 >uemtest.log 2>&1"
Command Line Options
The command line options used in this example are:
Option | Description |
---|---|
List of one or more hosts upon which a command may run. | |
Type of event to monitor. | |
Name or pattern of the file whose creation should be detected and tracked for completion. | |
Date and time at which the state of the monitored event should be made inactive. | |
ID of a remote user account that the UEM Server uses to establish the security context in which event monitoring is performed. | |
Password associated with -userid. | |
Event state that, when encountered, will result in the execution of the associated event handler. | |
Complete path to a local script file that contains one or more system commands that should be executed on behalf of the event handler. | |
Options that are passed as command line arguments to any process executed on behalf of an event handler. |
Contents of Sample Script File
The following figure illustrates the contents of the C:\UEMScripts\h_001.txt
file.
#!/bin/sh # Sample script h_001.txt argNum=1 # Display each command line argument. while [ "$1" != "" ] do echo Parm $argNum: $1 shift argNum=`expr $argNum + 1` done
Components
Universal Event Monitor Manager for Windows
Universal Event Monitor Server for UNIX