- Code: Select all
-- Schedule Indigo to run this script at 00:57 every hour
-- Do NOT include the word "error" in the name of this schedule or any other Indigo device, trigger, or group
set file1 to "/Library/Application Support/Perceptive Automation/Indigo 6/Logs/indigo_log.txt"
set file2 to "/Library/Application Support/Perceptive Automation/Indigo 6/Logs/Compare.txt"
set result1 to ""
try
do shell script "diff " & quoted form of file1 & space & quoted form of file2 & "| grep --ignore-case \"error\""
set result1 to result
end try
try
if result1 ≠ "" then
-- display dialog "Error" & result1
set value of variable "alarmCause" to "Indigo Log error:" & result1
execute group "Email Me"
-- assumes an Indigo action group to email you whatever is in the variable "alarmCause"
end if
end try
-- now copy current Log file over previous "Compare.txt" file for next time
do shell script "cp " & quoted form of file1 & space & quoted form of file2
The script above requires a second, short script scheduled just after midnight to prepare for tomorrow's first Log file:
- Code: Select all
-- Schedule Indigo to run this script every 12:01 am
set file1 to "/Library/Application Support/Perceptive Automation/Indigo 6/Logs/indigo_log.txt"
set file2 to "/Library/Application Support/Perceptive Automation/Indigo 6/Logs/Compare.txt"
try
do shell script "cp " & quoted form of file1 & space & quoted form of file2
end try
I wanted to make the first AppleScript into a "Folder Action", but I learned that there is no automatic action when a file is CHANGED -- only when a file is added or deleted. So I made this an Indigo schedule every hour. I hope you can use it.
- Joe