Execute Script for Triggered Event Occurrence - UNIX
Executing a Script for a Triggered Event Occurrence in UNIX
In this example, a UEM Server installed on a Windows 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 UEM Server working 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 /UEMScripts/h_001.txt
then will be written to a temporary script file on uemhost and executed by the 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 /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 /UEMScripts/h_001.txt file.
:: Sample script h_001.txt @echo off :: Program variables set parmCtr=1 :: Loop through parameter list :: **** Start of loop **** :BeginLoop if ""%1""=="""" goto EndLoop :DisplayParm echo Parm %parmCtr%: %1 :: Shift the next parm shift set /a parmCtr+=1 :: Go back to the top goto BeginLoop :: **** End of loop **** :EndLoop
Components
Universal Event Monitor Manager for UNIX
Universal Event Monitor Server for Windows