**Note:** We strongly recommend that you enter a full path to a script file as a command to event handlers. Although you can assign direct system commands, they might not work. Say, commands with output redirection operators `>`, `<`, `>>`, or `|` will not work.
## Running scripts via event handlers
For example, let’s store the names of new customers on the file system. To do this, first we should find the environment variable that contains the contact name. This variable is listed in the Administrator’s Guide , Appendix \> **Customer account created.**
As you can see, the variable name is *NEW_CONTACT_NAME*. Now we need to create an event handler.
To create the event handler on Linux:
1. Create a shell script (for example, `write-names.sh`) containing the following code:
1. Log in to Plesk, go to the **Tools & Settings** tab \> **Event Manager**.
2. Click **Add New Event Handler** and specify the following:
- **Event**. Select **Customer Account Created** from the menu.
- **Priority**. Leave set to lowest (0).
- **User**. Leave set to *root*.
- **Command**. Specify the path to the shell script created during step one (for example, `/tmp/write-names.sh`).
3. Click **OK**.
To create the event handler on Windows:
1. Create a batch file (for example, `write-names.bat`) containing the following code:
1. Log in to Plesk, go to the **Tools & Settings** tab \> **Event Manager**.
2. Click **Add New Event Handler** and specify the following:
- **Event**. Select **Customer Account Created** from the menu.
- **Priority**. Leave set to lowest (0).
- **User**. Leave set to *Plesk Administrator*.
- **Command**. Specify the path to the shell script created during step one (for example, `C:\Windows\Temp\write-names.bat`) and specify the variable name (as we discovered above, it is *new_contact_name*) in angle brackets. The result should look like this:
1. Click **OK**.
The event handler will be triggered every time a new customer account is created, and will write the customer’s contact name to the specified file.
For more details on event handlers, refer to the **Administrator’s Guide**, the chapter Event Tracking. This chapter provides instructions on how to create event handlers and describes environment variables related to each Plesk event.
#!/bin/bash
echo "Customer account has been created. Name: ${NEW_CONTACT_NAME}" >> /tmp/event_handler.log
echo "Customer account has been created. Name: %1" >> C:\Windows\Temp\event_handler.log
C:\Windows\Temp\write-names.bat <new_contact_name>