---
title: Reactive events in ProVide
description: "ProVide's Reactive features let the server react to events *after* they happen, by running batch scripts or sending custom messages. When something occurs on the server, such as a file finishing upload, a user logging in, or a user changing…"
url: "https://www.provideserver.com/resources/reactive/"
updated: "2026-09-17"
category: Advanced guides
---

# Reactive events in ProVide

ProVide's Reactive features let the server react to events *after* they happen, by running batch scripts or sending custom messages. When something occurs on the server, such as a file finishing upload, a user logging in, or a user changing directory, ProVide can automatically trigger a script or a notification in response. Because it can run external batch scripts, you can launch custom programs, call other tools, or perform almost any action you can script, all driven by real server events. Reactive is part of the Events and Messages module, available from the Maxi license.

A common example is automatically scanning uploaded files for viruses, but the same mechanism can drive thumbnails, backups, email and SMS notifications, and more.

## Examples

The examples below are just that, examples. You'll likely want to adapt the scripts or setup to suit your own needs. Each one pairs a ProVide **event** with a **message** that calls a script.

### 1. Send an SMS when a specific user logs in

Event in ProVide:

OnLoggedIn

Message in ProVide:

```javascript

                User logged in, proceed.%EXECUTE("C:ScriptsNotifyOnLoggedIn.cmd" %USERNAME%)%
```

Contents of file “C:\Scripts\NotifyOnLoggedIn.cmd”:

```javascript

                @echo off
rem Setup variables
set USER=
set PASS=
set TEXT=Login%%3A%1
set TO=555123456
set FROM=ProVideLogin

set PARAMS=acc=%USER%^^^&pass=%PASS%^^^&msg=%TEXT%^^^&to=%TO%^^^&from=%FROM%^^^&prio=3
rem Notify on certain users logging in
if /I “%1” == “Administrator” wget –delete-after http://smsgateway/send.php?%PARAMS% >NUL
if /I “%1” == “Backup” wget –delete-after http://smsgateway/send.php?%PARAMS% >NUL
if /I “%1” == “John” wget –delete-after http://smsgateway/send.php?%PARAMS% >NUL
```

### Scan uploaded files for viruses with AVG

This example illustrates how to use AVG to scan uploaded files for viruses. The script requires AVG to be installed.

Event in ProVide:

OnUploadEnd

Message in ProVide:

```javascript

                Closing data connection.%EXECUTE("C:ScriptsScan.cmd" "%LOCAL_FILENAME%")%
```

Contents of file "C:\Scripts\Scan.cmd":

```javascript

                @echo off
"C:ProgramAVGAVG8AVGSCANX.EXE" /HEUR /ARC /CLEAN /SCAN=%
```

### Create thumbnails of uploaded images

Event in ProVide:

OnUploadEnd

Message in ProVide:

```javascript

                Closing data connection.%EXECUTE(“C:ScriptsCreateThumbnail.cmd” “%LOCAL_FILENAME%”)%
```

Contents of file "C:\Scripts\CreateThumbnail.cmd":

```javascript

                @echo off
rem Extract file information and remove quotes
set FILE=%1
for /f "useback tokens=*" %%a in ('%FILE%') do set FILE=%%~a
set EXT=
if /I "%FILE:~-4%" == ".jpg" set EXT=.jpg
if /I "%FILE:~-4%" == ".gif" set EXT=.gif
if /I "%FILE:~-4%" == ".tif" set EXT=.tif
rem Only create thumbnails from selected formats
if (%EXT%) == () exit 0
rem We know all accepted formats have 3 character extensions
set THUMBFILE=%FILE:~0,-4%-thumbnail%EXT%
rem Use ImageMagick to create thumbnails
convert "%FILE%" -resize 100x100 -quality 90 "%THUMBFILE%" >NUL
```

### Automatically backup a file before it is to be overwritten

Event in ProVide:

OnUploadStart

Message in ProVide:

```javascript

                File status okay; about to open data connection.%EXECUTE(“C:ScriptsBackup.cmd” “%LOCAL_FILENAME%”)%
```

Contents of file “C:\Scripts\Backup.cmd”:

```javascript

                @echo off
rem Extract file information and remove quotes
set FILE=%1
for /f “useback tokens=*” %%a in (‘%FILE%’) do set FILE=%%~a
rem Perform the backup
copy /v /y “%FILE%” “%FILE%.bak” >NUL
```

### Send email on upload to a specific folder

This example illustrates how to send a mail notification after a file has been uploaded to a specific folder. It also does a virus scan before sending the mail. It uses a separate script to generate the email data. This is done to get correct linefeeds in the email format. It also acts as a template for the email.

Event in ProVide:

OnUploadEnd

Message in ProVide:

```javascript

                Closing data connection.%EXECUTE(“C:ScriptsMailOnUploadEnd.cmd” “%LOCAL_FILENAME%” “%FTP_FILENAME%”)%
```

Contents of file "C:\Scripts\MailOnUploadEnd.cmd":

```javascript

                @echo off
REM Filenames may need special character codes.
chcp 1252
REM Virus scan the file, only send mail if the file still exists after the scan.
“C:Program FilesAVGAVG2012AVGSCANX.EXE” /HEUR /ARC /CLEAN /TRASH /SCAN=%1
IF EXIST “%1” (
REM Only send mail for a specific folder.
SET FOLDER_FILTER=Share this
SET FOLDER_UPLOAD=%~p2
IF “%FOLDER_FILTER%”==”%FOLDER_UPLOAD%” ( C:ScriptsMailTemplate.cmd %2 | C:Scriptsmsmtpmsmtp.exe mailinglist@example.net )
)
```

Contents of file “C:\Scripts\MailTemplate.cmd”:

```javascript

                @echo off
setlocal enableDelayedExpansion
set NL=^
REM Two empty lines required for newlines to work
echo SUBJECT:New file uploaded %~nx1!NL!
echo And here’s a link to it.!NL!http://www.test.com/%~nx1!NL! EndLocal
```

### Call a bash script through cygwin when user change directory

Event in ProVide:

OnChangeDirectory

Message in ProVide:

```javascript

                %EXECUTE(“C:cygwin64binbash” “C:Scriptsparse.sh” “%FTP_DIRECTORY%” “%FTP_FILENAME%”)%
```

Message in ProVide:

```javascript

                #!/bin/bash
echo -n “Change dir from ” >> /cygdrive/x/cwd.log
echo -n $1 >> /cygdrive/x/cwd.log
echo -n ” to ” >> /cygdrive/x/cwd.log
echo $2 >> /cygdrive/x/cwd.log
```
