############################################################################################## # Version: 3.04 # Author: Paul Ponting # Modified: 19/02/2001 # # # ***** VERY IMPORTANT INFORMATION ***** # # 1 - All changes to this script must be authorised by means of an RFC. # # 2 - All modifications, however small must be recorded in the modification history section. # A single mistyped character can affect ALL sites within UB and this history will help # in troubleshooting such errors. # # 3 - This script MUST be called from another script. It will abort if ran standalone. # ############################################################################################## # # MODIFICATION HISTORY (Newest at the top) # ---------------------------------------- # # 22/2/2001 # Added logic tocreate a *.OK file for completed jobs # Paul Ponting # # 19/02/2001 # Upgraded to taslmstr.nlm v3.10a # Added the /-T option on SYNC command (/-T = no trustees) # Paul Ponting # # 14/02/2001 # Added more info to the script.RUN file to indicate time and date the script started. # Paul Ponting # # 16/08/2000 # Changed base directory to VOL1:REPORTS\REPLICAT # Paul Ponting # # 16/08/2000 # Added variable %6 IGNORE.DAT location # # 15/08/2000 # Added logic to check for NALVOL.TXT on destination volume before SYNC'ing # Paul Ponting # # 15/08/2000 # Tidying up of script. Changing case of reserved words to uppercase. Changing end # statements to ENDIF statements # Paul Ponting # # 15/08/2000 # Added log file generation in STATUS directory for REPLICAT.LGG to trap errors # not logged anywhere else. # Paul Ponting # # 15/08/2000 # Error level variable added (%7) # Paul Ponting # # 15/08/2000 # Check of passed in variables. # Paul Ponting # # 10/08/2000 # Destination volume variable added (%3) # Paul Ponting # ############################################################################################## # # RESERVED VARIABLES: DO NOT ASSIGN : # %9 General purpose - Used internal to script # %8 Working directory - Used internal to script # %7 Error Level - Used Internal to mark current error level. # %6 ignore.dat Location - Used internal to script # %5 -- NOT Assigned # %4 -- NOT Assigned # %3 Destination Volume - Passed from calling script # %2 Archive history count - Passed from calling script # %1 Log File Name - Passed from calling script # %0 Server Name - Passed from calling script # # ERROR LEVELS (Variable %7) # # 00 - No Error # 01 - Passed Variables error # 02 - No NOL marker file on destination # 03 - errors in log file # ############################################################################################ # Start of Script # ########################################################################################### # Sets error level to 00 DEFINE %7 00 # Defines a working directory that all system access should use to allow easier transfer # of script to another location. (no trailing backslash) # i.e. # DEFINE %8 VOL1\TASKS (This must already exist) # VOL1:\TASKS\ARCHIVE\STATUS (This would be automatically created) # VOL1:\TASKS\ARCHIVE\%1 (This would be automatically created from variable %1) DEFINE %8 VOL1:REPORTS\REPLICAT IF NOT EXIST %8\ ABORT ENDIF #Sets location of ignore.dat file DEFINE %6 SYS:SYSTEM\TASKMSTR\TASKS # Checks for the STATUS directories. Creates if it doesn't exist. # They are created early on so errors in variable passing can be logged to this directory. IF NOT EXIST %8\STATUS\ MD %8\STATUS ENDIF # Basic check to ensure the passed in variable actually contain data. If they dont, the # script aborts. IF "%0"=="" THEN DEFINE %7 01 IF "%1"=="" THEN DEFINE %7 01 IF "%2"=="" THEN DEFINE %7 01 IF "%3"=="" THEN DEFINE %7 01 IF "%7"=="01" THEN BEGIN OPEN_WRITE %8\STATUS\REPLICAT.LGG WRITE %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% - %HOUR24%:%MINUTE%:%SECOND% WRITE Error in variable passing - Task Aborted. WRITE CLOSE ABORT ENDIF # Checks for log directory named after variable %1. Creates if it does not exist # This is not created with the other directory creations as this creation is based # on a passed variable. Passed variables must be verified before this is created. IF NOT EXIST %8\%1\ MD %8\%1 ENDIF /////////////////////////////////////////////////////////////////////////////////////////// # Checks for Error file of current server being processed. Deletes if it exists IF EXIST %8\STATUS\%1.ERR DEL %8\STATUS\%1.ERR ENDIF IF EXIST %8\STATUS\%1.NOT DEL %8\STATUS\%1.NOT ENDIF IF EXIST %8\STATUS\%1.OK DEL %8\STATUS\%1.OK ENDIF # Check if script is already running. # Checks if log file is present and in use, if so, abort. # If it exist but not in use, log is deleted and script continues. IF EXIST %8\%1\%1.LGG IF FILE_IN_USE %8\%1\%1.LGG THEN BEGIN DEFINE %7 03 OPEN_WRITE %8\%1\ABORT.LGG WRITE %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% - %HOUR24%:%MINUTE%:%SECOND% WRITE Task Aborted, SYNC already in progress CLOSE ABORT ENDIF DEL %8\%1\%1.LGG ENDIF # Creates markers file to indicate script is running at a glance. IF NOT EXIST %8\STATUS\%1.RUN OPEN_WRITE %8\STATUS\%1.RUN WRITE Script currently runnning WRITE WRITE Started: WRITE Day : %DAY_OF_WEEK% WRITE Date: %DAY%/%MONTH%/%YEAR% WRITE Time: %HOUR24%:%MINUTE%:%SECOND% WRITE WRITE If this script has been running in excess of 12 hours, then there may be a problem. CLOSE ENDIF # Creates a new empty log file named after destination server # Writes task information to it, start time and date then closes it. OPEN_WRITE %8\%1\%1.LGG /TRUNC WRITE Task: Replicate apps to %0 WRITE Started at %HOUR24%:%MINUTE%:%SECOND% on %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% WRITE CLOSE # Test for presence of NAL_Volume_Marker on destination volume IF NOT EXIST %0/%3:\NALVOL.TXT THEN BEGIN OPEN_WRITE %8\%1\%1.LGG WRITE ??? Error - NALVOL.MRK not present on destination volume CLOSE ENDIF # SYNC local Servers ADMIN volume to destination Servers ADMIN volume # See help for switch information, uses IGNORE.DAT file to ignore certain files from SYNC # appends to log file what was sync'ed IF EXIST %0/%3:\NALVOL.TXT THEN BEGIN SYNC ADMIN:\*.* %0/%3: /-T /F /A /D /V /I /S /H <%6\IGNORE.DAT >>%8\%1\%1.LGG ENDIF # Opens log file and inserts finishing time and SYNC duration OPEN_WRITE %8\%1\%1.LGG WRITE WRITE WRITE Finished at %HOUR24%:%MINUTE%:%SECOND% on %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% WRITE Total running time %ELAPSED_TIME% (hh:mm:ss). CLOSE # Deletes any log files older than defined by variable %2 # up to max of 99.LGG DEFINE %9 %2+=1 while %9 < 99 if exist %8\%1\%9.LGG del %8\%1\%9.LGG end define %9 %9+=1 loop # Defines temporary variable %9 to equal %2 -1 define %9 %2-=1 # Deletes oldest logfile if it exists as defined by variable %2 if exist %8\%1\%2.LGG del %8\%1\%2.LGG end # This loop renames each file to the next number up, i.e. 05.LGG becomes 06.LGG # %9 and %2 are decreased by 1 after each loop until %9 equals 00 # Starts loop from %2 - 1 down to 0. while %9 > 00 if exist %8\%1\%9.LGG rename %8\%1\%9.LGG %8\%1\%2.LGG end define %9 %9-=1 define %2 %2-=1 loop # Renames the newest logfile to 01.LGG if exist %8\%1\%1.LGG rename %8\%1\%1.LGG %8\%1\01.LGG ENDIF # Checks for errors in the most recent log file (01.lgg). If any are present, creates an error # file named after the server name in the STATUS directory. OPEN_READ %8\%1\01.LGG IF ERRORLEVEL ABORT ENDIF WHILE READ %9 IF ERRORLEVEL THEN BREAK DEFINE %7 00 IF "%9"=="" THEN CONTINUE IF SCAN_STRING "???" "%9" OPEN_WRITE %8\STATUS\%1.ERR WRITE Errors Found %HOUR24%:%MINUTE%:%SECOND% on %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% CLOSE DEFINE %7 03 BREAK ENDIF IF SCAN_STRING "***" "%9" OPEN_WRITE %8\STATUS\%1.NOT WRITE Notices Found %HOUR24%:%MINUTE%:%SECOND% on %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% CLOSE DEFINE %7 03 BREAK ENDIF LOOP IF "%7"=="00" OPEN_WRITE %8\STATUS\%1.OK WRITE SYNC successful %HOUR24%:%MINUTE%:%SECOND% on %DAY_OF_WEEK%, %DAY%/%MONTH%/%YEAR% WRITE Total running time %ELAPSED_TIME% (hh:mm:ss). CLOSE END # Deletes marker file to indicate script is not running. IF EXIST %8\STATUS\%1.RUN DELETE %8\STATUS\%1.RUN ENDIF