To add an event handler:
For instance, let's create an event handler for the 'client account creation' event. The handler will accept a client name as the first parameter, and the client's login as the second. For simplicity we will use a batch file called test-handler.bat that looks as follows:
echo "--------------" >> c:\windows\temp\event_handler.log
rem information on the event date and time
date /T >> c:\windows\temp\event_handler.log
rem information on the created client account
echo "client created" >> c:\windows\temp\event_handler.log
rem client's name
echo "name: %1" >> c:\windows\temp\event_handler.log
rem client's login
echo "login: %2" >> c:\windows\temp\event_handler.log
echo "--------------" >> c:\windows\temp\event_handler.log
This script prints some information to a file so that we could control its execution.
Suppose, that our script is located in the directory c:\program files\parallels\plesk\scripts\
. Let's register it by creating an event handler via the control panel:
When assigning several handlers to a single event you can specify the handler execution sequence, setting different priorities (higher value corresponds to a higher priority).
c:\program files\parallels\plesk\scripts\test-handler.bat" <new_contact_name> <new_login_name>
.Note that if directory names or the file name contains spaces, the path should be quoted.
Note: In the command, we have specified the variables in the angle brackets <new_contact_name>
and <new_login_name>
. During execution of the handler, they will be replaced with name and login of the created client respectively. The entire list of available variables is provided in the section Events and Variables Passed by Event Handlers on Windows Systems.
You should keep in mind that with the removal operations, the parameters of type new_xxx contain an empty string. And with creation operations the parameters of type old_xxx contain an empty string.
Now if you login to your Parallels Plesk Panel and create a new client, specifying the value 'Some Client' in the Contact name field, and 'some_client' in the field Login, the handler will be invoked, and the following records will be added to the c:\windows\temp\event_handler.log
:
Sat Jun 26 21:46:34 NOVT 2004
client created
name: Some client
login: some_client
If you want to specify one or few handlers more, repeat the actions above for another handler.