Simon icon Simon
Flexible server monitoring

Filter script to find deleted content?

Hi script experts!

I had a query that seems fairly simple, but has defeated me... though I think I'm close. The user wanted to be notified if someone deletes a file from a FTP directory. It's easy to get the FTP directory list, via the appropriately-named FTP Directory Listing service. And a simple Change filter will list any change. But it won't show deleted content.

So, my thought was to create a Script-based filter, and use the diff command to detect the changes, including deletions.

My initial thought was to use the {FilterPreviousText} variable, but that would just show the previous diff output, which isn't very helpful.

So I came up with the following script, which saves the filter input (i.e. the output from the service) to a file, compares it to what it was before (saved in a "previous" file), then updates the previous file for next time. In theory this should work, but it doesn't output anything, even when there is a change. Probably something obvious to anyone more familiar with shell scripts. Can anyone help? Or offer a better solution?

mkdir -p /tmp/dejal/simon/{TestIdentifier}/diff
cd /tmp/dejal/simon/{TestIdentifier}/diff


echo $input_text > input

diff previous input

echo $input_text > previous