//////////////////////////////////////////////////////////////////////////////// // // Task: SYNCLOG.TSK // (Sample logic that can be included in a SYNC task to check for // errors in the log file and send an E-Mail with only the errors.) // Author: Avanti Technology, Inc. // http://www.avanti-tech.com // Version: 1.0 - Initial Release // 1.1 - New & Improved // // Description: // ============ // Insert this logic after a SYNC command to check the output redirect log file // for errors and send them to the appropriate people. // // Objective: // ========== // Automate notification if SYNC encounters a problem. // // Usage: // ====== // Not meant to be a stand-along script (though it can be with slight mods) // but an add-on / insert to a SYNC task needing error notification. // // Compatibility: // ============== // This task has been tested on the following platforms without demonstrating // any compatibility issues or any other reported/confirmed conflicts: // TaskMaster v4.02 (or later) // NetWare v5.x / v6.x (including OES NetWare) // // Warning: // ======== // AS WITH ANY NEW SOFTWARE PROGRAM, BATCH SCRIPT, OR AUTOMATED PROCESSING // PROCEDURE, CAUTION SHOULD BE EXERCISED AND DUE DILIGENCE OBSERVED DURING // INITIAL IMPLEMENTATION. WHERE POSSIBLE, TESTING SHOULD BE PERFORMED ON // NON-PRODUCTION SYSTEMS PRIOR TO FULL IMPLEMENTATION. // //////////////////////////////////////////////////////////////////////////////// // It is assumed that the variable %SYNC_LOG% has been previously defined // in the script to designate the output redirection log for the SYNC. // If not, all instances of %SYNC_LOG% in this task need to be replaced with // the appropriate output redirection log file for the SYNC. // Open the SYNC output redirection log so it can be checked for errors OPEN READ #0 %SYNC_LOG% // ABORT if error encountered opening SYNC output redirection log file IF ERRORLEVEL THEN ABORT // Make sure any extraneous or left over E-Mail files deleted IF EXIST %TASK_PATH%\%TASK_FILE%.EML THEN DELETE %TASK_PATH%\%TASK_FILE%.EML // Loop to scan for errors in SYNC output redirection log file WHILE // Read first / next line in SYNC output redirection log file READ #0 %0 // Check for error or End Of File (EOF) and abort if either IF ERRORLEVEL THEN BREAK // Check for null line (CR/LF only) - read next record if null IF "%0"=="" THEN CONTINUE // Check for error ( where errdesc varies by error) // Note: Must have both < and > or read next record IF NOT SCAN_STRING "<" "%0" OR NOT SCAN_STRING ">" "%0" THEN CONTINUE // Check if first error found (i.e.,. E-Mail text file does not exist) IF NOT EXIST %TASK_PATH%\%TASK_FILE%.EML // Open a temporary output file for the E-Mail text // Name is built from the active Task Path / File Name, // excluding extension, with a .EML extension appended. OPEN WRITE #0 %TASK_PATH%\%TASK_FILE%.EML TRUNCATE // ABORT task is error opening E-Mail output (no need to continue) IF ERRORLEVEL THEN ABORT // Write the basic E-Mail message header // Notes: To: & From: required, Subject: optional (Date: auto generated) // Replace name@domain.cci as appropriate for To: / From: lines. // CC: and BCC: can also be added (cut/paste/modify To: line). // For multiple To: / CC: / BCC: recipients, use separate line // for each recipient (E-Mail address). WRITE #0 To: name@domain.cci WRITE #0 From: name@domain.cci WRITE #0 Subject: SYNC Error Summary (from %SYNC_LOG%) WRITE #0 WRITE #0 The following errors were extracted from: %SYNC_LOG% WRITE #0 ENDIF // Add error record to E-Mail WRITE #0 %0 LOOP // Check if any errors found (E-Mail file will not exist of none) IF EXIST %TASK_PATH%\%TASK_FILE%.EML // Close E-Mail output file CLOSE WRITE #0 // Send E-Mail output file // Note STMP Server must be a full URL or dot.notated address TMSMTP [smtp_server_url | smtp_server_ip] %TASK_PATH%\%TASK_FILE%.EML // Cleanup temporary E-Mail output file DELETE %TASK_PATH%\%TASK_FILE%.EML ENDIF // Close SYNC output redirection log file CLOSE READ #0