home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
netdor3.zip
/
DISK_12
/
IMAGE11.ZIP
/
ADMTOOLS
/
verimage.cmd
< prev
Wrap
OS/2 REXX Batch file
|
1993-09-02
|
47KB
|
850 lines
/* VerIMAGE - Read the Contents.COR file and check if all the files
* exist on the Image disk.
* Author: Tom Heald (Heald at Almaden)
*****************************************************************************
* Licensed Materials-Property of IBM *
* 5604-472 (c) Copyright IBM Corporation, 1993 *
* All rights reserved. *
* US Government Users Restricted Rights - *
* Use, duplication or disclosure restricted *
* by GSA ADP Schedule Contract with IBM Corp. *
*****************************************************************************
* Change History:
* 11/14/91 - ATH - Fix WasteBin problem.
* 1/20/92 - ATH - Fix to look for filespec's with blanks.
* 7/24/92 - ATH - Total rewrite to do more checking etc. Changed lines
* are not marked.
* 7/30/92 - ATH - Only set the error return code on missing files for now!
* Change COREList.Fil to Contents.Cor
* 8/04/92 - ATH - Change the way Contents.Cor is checked.
* 8/06/92 - ATH - Change start of data for sort.
* 8/10/92 - ATH - Change to call RxStemSort.
* 8/12/92 - ATH - Add the /Sunc option.
* 9/23/92 - ATH - Update Help Text.
* 9/25/92 - ATH - Add the Retry and List options.
* 10/06/92 - ATH - Use XCopy and check Date/Time/Size after copy.
* 10/16/92 - ATH - Add NetClose option
* 10/29/92 - ATH - Remove need for response file.
* 11/09/92 - DSK - Add CMD_Name reference. Change to YKT NOTIFY.CMD
* 11/13/92 - ATH - Add CODE to check for empty directories.
* 4/27/93 - ATH - Add LOG option to change the name of the log file.
**********************************************************************/
Trace "O"
"@ECHO OFF"
Debug = 0
Time_Run = 1
TS_This = Time('E')
Target_File = "CONTENTS.COR" /* Must be upper case ATH 7/30/92 */
Target_Bak = "CONTENTS.BAK" /* Backup file name ATH 8/12/92 */
Temp_File = "VerIMAGE.TMP" /* Temp file name to download 8/12/92 */
Output_File = "VerIMAGE.Log"
NetClose = 'NetClose.Exe' /* NetClose Command FSpec ATH 10/16/92 */
Server_Alias = '' /* NetClose Server ATH 10/16/92 */
New = 0 /* Replace flag off ATH 8/12/92 */
Rep = 1 /* Replace flag on ATH 8/12/92 */
Copied_Ct = 0 /* Count good copies ATH 10/06/92 */
Download_Ct = 0 /* Error Counter */
Backlevel_Ct = 0 /* Error Counter */
Missing_Ct = 0 /* Error Counter */
Erase_Ct = 0 /* Error Counter */
Error_Ct = 0 /* Error Counter */
Dir_Ct = 0 /* Error Counter ATH 11/13/92 */
Dir_List.0 = 0 /* Directories to erase. ATH 11/13/92 */
Send_Msg = 0 /* No Error Msg */
Erase_Old = 0 /* Do not erase old files */
Ask_User = 1 /* Ask the user to verify all erases */
Sync_Image = 0 /* do not sync the machine. */
List_Only = 0 /* Create Contents.Cor file to test. ATH 9/25/92 */
Retry_Count = 3 /* Default Retry count ATH 9/25/92 */
Net_Close = 0 /* Default to no NetClose ATH 10/16/92 */
Parse Upper Source . CMD_Type CMD_FS . /* Get Prog info ATH 10/16/92 */
CMD_I = lastpos('\', CMD_FS) /* End of path ATH 10/16/92 */
CMD_Path = Left(CMD_FS, CMD_I) /* Get Path ATH 10/16/92 */
CMD_FN = SubStr(CMD_FS, CMD_I+1) /* Get filename ATH 10/16/92 */
Parse Var CMD_FN CMD_Name '.' Cmd_Ext /* Get Name & ext ATH 10/16/92 */
Parse upper Arg Core_Dir junk "/" Option etc
Do while Option <> ""
Select
When Abbrev("MESSAGE", Option,1) Then Call Set_Msg;
When Abbrev("MSG", Option,1) Then Call Set_Msg;
When Abbrev("NEW", Option,1) Then Call Erase_File Output_File;
When Abbrev("ERASE", Option,1) Then Erase_Old = 1
When Abbrev("YES", Option,1) Then Ask_User = 0
When Abbrev("DEBUG", Option,1) Then Debug = 1
When Abbrev("LIST", Option,2) Then List_Only = 1 /* ATH 4/29/93 */
When Abbrev("LOG", Option,2) Then Do /* ATH 4/27/93 */
Parse Var etc Log_File etc /* Get filename ATH 4/27/93 */
If Log_File = "" /* ATH 4/27/93 */
Then Do /* ATH 4/27/93 */
Say 'The name of the Log file must follow the "/'Option'" option.'
Call Exit_RC 1 /* ATH 4/27/93 */
end /* ATH 4/27/93 */
Else Output_File = Log_File /* Set output ATH 4/27/93 */
end /* ATH 4/27/93 */
When Abbrev("SYNC", Option,1) Then Do /* ATH 8/12/92 */
Sync_Image = 1 /* Set the option ATH 8/12/92 */
Parse Var etc Master_CORE etc /* Get name ATH 8/12/92 */
If Master_CORE = "" /* ATH 8/12/92 */
Then Do /* ATH 8/12/92 */
Say 'The Remote NetDoor directory is missing after the "/Sync" option.'
Call Exit_RC 1 /* ATH 10/16/92 */
end /* ATH 8/12/92 */
If Right(Master_CORE,1) <> "\" Then Master_CORE = Master_CORE"\"
end /* ATH 8/12/92 */
When Abbrev("RETRY", Option,1) Then Do /* ATH 9/25/92 */
Parse Var etc Retry_Count etc /* Get count ATH 9/25/92 */
If \datatype(Retry_Count,n) /* ATH 9/25/92 */
Then Do /* ATH 9/25/92 */
Say 'The retry count must be a numeric value.'
Call Exit_RC 1 /* ATH 10/16/92 */
end /* ATH 9/25/92 */
end
When Abbrev("NETCLOSE", Option,4) Then Do /* ATH 10/16/92 */
Parse Var etc NC_Path etc /* Path to close ATH 10/16/92 */
If Right(NC_Path,1) <> "\" Then NC_Path = NC_Path"\" /* ATH 10/16/92 */
'DIR' NC_Path'*.* >nul 2>&1' /* Test Path ATH 10/16/92 */
If RC <> 0 Then Do /* Any problems? ATH 10/16/92 */
Say 'The NetClose path "'NC_Path'" can not be found.' /* ATH 10/16/92 */
Call Exit_RC 1 /* ATH 10/16/92 */
end /* ATH 10/16/92 */
NC_Exe = RxSearchPath("PATH", NetClose) /* ATH 10/16/92 */
If NC_Exe = "" /* ATH 10/16/92 */
Then Do /* ATH 10/16/92 */
Say 'The "'NetClose'" command was not found.' /* ATH 10/16/92 */
Say 'Add it to the search path before using this option.' /* ATH 10/16/92 */
Call Exit_RC 1 /* ATH 10/16/92 */
end /* ATH 10/16/92 */
Else NetClose = NC_Exe /* ATH 10/16/92 */
Net_Close = 1 /* Set the option ATH 10/16/92 */
end /* ATH 10/16/92 */
Otherwise Do;
Say 'Invalid Option:' Option
Call Exit_RC 2 /* ATH 10/16/92 */
End
End /* Select */
Parse var etc junk "/" Option etc
End /* Do while */
If Core_Dir = ""
Then Do
Say "The drive and path are required input. i.e. VerImage W:\ or VerImage D:\DOOR01\"
Call Exit_RC 2 /* ATH 10/16/92 */
End
If Core_Dir = ? Then Signal Help
If Abbrev("HELP", Core_Dir,1) Then Signal Help;
If Right(Core_Dir,1) <> "\" Then Core_Dir = Core_Dir"\"
Core_Root = Left(Core_Dir,3)
Input_File = Core_Dir || Target_File
/* Add List Only Subroutine ATH 9/25/92 */
If List_Only Then Do /* Do we want to make a list? */
Call List_CORE_Dir /* List and sort the CORE Dir. */
If Time_Run Then Say 'Writing "'Input_File'" at' Time_Stamp()
RC = RxWrite(Input_File,"CORE_Disk") /* Write list */
If Time_Run Then Say 'Write Return Code = "'RC'" at' Time_Stamp()
Call Exit_RC 0 /* ATH 10/16/92 */
end
If Sync_IMAGE Then Do /* Do we want to Sync CORE? ATH 8/12/92 */
Master_File = Master_CORE || Target_File /* ATH 8/12/92 */
Master_Temp = CORE_Dir || Temp_File /* ATH 8/12/92 */
If RxFileExist(Master_File) Then Do /* ATH 8/12/92 */
If Time_Run Then Say 'Getting "'Input_File'" at' Time_Stamp()
"ECHO NO | XCOPY" Master_File Master_Temp '>nul 2>&1' /* Get file ATH 10/06/92 */
If RC = 0 /* Any errors? ATH 8/12/92 */
Then Do /* If OK then rename the temp file ATH 8/12/92 */
Call RxTree Input_File, 'Temp', 'F', '*****', '***-*'
If Temp.0 > 0 then 'Erase' Input_File /* Erase old file. ATH 8/12/92 */
'Rename' Master_Temp Target_File /* New one ATH 8/12/92 */
end /* ATH 8/12/92 */
Else Do /* if error erase temp and exit. ATH 8/12/92 */
If RxFileExist(Master_Temp) Then 'Erase' Master_Temp
Say 'Error downloading "'Master_File'".' /* ATH 8/12/92 */
Call Exit_RC 2 /* ATH 10/16/92 */
end
end /* If RxFileExist Then do */
else Do /* Can't find the Master list file ATH 8/12/92 */
Say '"'Master_File'" does not exist.' /* ATH 8/12/92 */
Call Exit_RC 2 /* ATH 10/16/92 */
end /* If RxFileExist Else do ATH 8/12/92 */
end /* If Sync_IMAGE */ /* ATH 8/12/92 */
/* Move Subroutine from before /sync code ATH 9/25/92 */
If Stream(Input_File,'c','query exists') = ""
Then Do
Say Input_File "does not exist."
Call Exit_RC 2 /* ATH 10/16/92 */
End
Call Get_Input_File /* Read and sort the input file ATH 9/25/92 */
Call List_CORE_Dir /* List and sort the CORE Dir. ATH 9/25/92 */
L1 = 0 /* init CORE_Disk index */
D1 = 0 /* init CORE_Disk index */
L_Spec = X2C(00) /* init */
D_Spec = L_Spec /* init */
End_Of_File = 0 /* init */
End_Of_List = 0 /* init */
If Time_Run Then Say 'Comparing "'CORE_Dir'" lists at' Time_Stamp()
Call Get_List_Rec /* Get first record */
Call Get_Disk_Rec
Do Until End_Of_File + End_Of_List = 2
If Debug Then Say 'Comp. "'L_Spec'" to "'D_Spec'".'
Select
When L_Spec = D_Spec Then Do /* When equal check Date, Time & size */
If L_Date <> D_Date | L_Time <> D_Time | L_Size <> D_Size
Then Call Error_Equal
Call Get_List_Rec /* Get the Next records */
Call Get_Disk_Rec
end
When L_Spec < D_Spec Then Do /* When low file missing locally */
Call Error_Low
Call Get_List_Rec /* Get the Next record */
end
Otherwise Do /* When High file should be erased locally */
Call Error_High
Call Get_Disk_Rec /* Get the Next record */
End
End /* Select */
End /* Do Until */
Do Dir_I = Dir_List.0 to 1 by -1 /* Remove empty dir. ATH 11/13/92 */
Dir_Spec = Dir_List.Dir_I /* ATH 11/13/92 */
Parse Var Dir_List.Dir_I D_Date D_Time D_Size D_Spec /* 11/13/92 */
If Erase_Old Then Do /* Only remove if told to ATH 11/13/92 */
'RmDir "'D_Spec'"' /* ATH 11/13/92 */
If RC = 0 /* All ok? ATH 11/13/92 */
Then Log_Msg = "(Removed)" /* Yes ATH 11/13/92 */
Else Do /* No ATH 11/13/92 */
Log_Msg = "(RmDir RC =" RC")" /* ATH 11/13/92 */
Dir_Ct = Dir_Ct + 1 /* ATH 11/13/92 */
end /* ATH 11/13/92 */
end /* If Erase_Old Then */
Else Do /* Tell the user about the empty Dir. ATH 11/13/92 */
Log_Msg = '(Should be removed)' /* Empty dir ATH 11/13/92 */
Dir_Ct = Dir_Ct + 1 /* Error count ATH 11/13/92 */
end
Fill_Ct = 30 - Length(D_Spec) /* ATH 11/13/92 */
If Fill_Ct < 0 then Fill = ""; else Fill = Left(" ",Fill_Ct)
Out_Line = Right(D_Date,8) Right(D_Time,6) Right('Dir',8) D_Spec ,
Fill || Log_Msg /* ATH 11/13/92 */
Call Log_Output /* ATH 11/13/92 */
end /* Do Dir_I */ /* ATH 11/13/92 */
If Time_Run Then Say ' End of "'CORE_Dir'" compare at' Time_Stamp()
Call Lineout Output_File /* Close the output file */
Error_Ct = Backlevel_Ct + Missing_Ct + Erase_Ct ,
+ Download_Ct + Dir_Ct /* ATH 11/13/92 */
Say
If Download_Ct > 0 Then Do /* ATH 8/12/92 */
If Download_Ct > 1 Then s = 's'; else s = '' /* ATH 8/12/92 */
Say Download_Ct 'error's' downloading from "'Master_CORE'".'
end
If Backlevel_Ct > 0 Then Do /* ATH 8/04/92 */
If Backlevel_Ct > 1 Then s = 's'; else s = '' /* ATH 8/04/92 */
Say Backlevel_Ct 'wrong level file's' found. (Date, time or size difference.)'
end
If Missing_Ct > 0 Then Do /* ATH 8/04/92 */
If Missing_Ct > 1 Then s = 's'; else s = '' /* ATH 8/04/92 */
Say Missing_Ct 'missing file's' detected.'
end
If Erase_Ct > 0 Then do /* ATH 8/04/92 */
If Erase_Ct > 1 Then s = 's'; else s = '' /* ATH 8/04/92 */
Say Erase_Ct 'extra file's' found that should be erased.'
end
If Dir_Ct > 0 Then do /* ATH 11/13/92 */
If Dir_Ct > 1 Then s = 'ies'; else s = 'y' /* ATH 11/13/92 */
Say Dir_Ct 'empty director's' found that should be removed.'
end
If Error_Ct + Copied_Ct + Dir_List.0 > 0 /* A log ent. ATH 11/13/92 */
Then Do /* If there were any log entries add a Error Ct line. */
If Error_Ct <> 1 Then s = 's'; else s = '' /* ATH 8/04/92 */
Out_Line = Error_Ct 'Error's' found in the "'Core_Dir'" directory on' Date(u) 'at' Time()'.'
If Error_Ct > 0 Then Say Out_Line /* ATH 10/16/92 */
Call LineOut Output_File, Out_Line
if Result = 1 then Signal Write_Err
End
If Error_Ct = 0 /* Any errors at all? */
Then Do
Ret_Code = 0
Say 'All "'Core_Dir'" files present and accounted for on' Date(u) 'at' Time()'.'
End
Else Do /* ATH 10/16/92 */
Ret_Code = 3 /* ATH 10/16/92 */
End /* ATH 10/16/92 */
Call Exit_RC Ret_Code /* ATH 10/16/92 */
/*------------------------ Sub Routines --------------------------------*/
/*----------------------------------------------------------------------*/
/* Make inline code a subroutine ATH 9/25/92 */
Get_Input_File:
If Time_Run Then Say 'Reading "'Input_File'" at' Time_Stamp()
RC = RxRead(Input_File,"CORE_List") /* Read the List of files from COREUp */
If RC <> 0 then Signal Read_Err
Do I1 = 1 to CORE_List.0
CORE_List.I1 = Translate(CORE_List.I1) /* All Upper case */
end
If Time_Run Then Say 'Sorting "'Input_File'" at' Time_Stamp()
SS_In = Pos(":\", CORE_List.1) + 2 /* ATH 8/10/92 */
Call RxStemSort "CORE_List", "A", SS_In /* ATH 8/10/92 */
If Debug Then Do I1 = 1 to CORE_List.0
Say Right(I1,3) CORE_List.I1
end
Return
/*----------------------------------------------------------------------*/
/* Make inline code a subroutine ATH 9/25/92 */
List_CORE_Dir:
If Time_Run Then Say 'Listing files on "'CORE_Dir'" at' Time_Stamp()
/* RC = RxTree(CORE_Dir,"CORE_Disk", "SF") List files on CORE Disk */
RC = RxTree(CORE_Dir,"CORE_Disk", "SB") /* List files. ATH 11/13/92 */
Do I1 = 1 to CORE_Disk.0
CORE_Disk.I1 = Translate(CORE_Disk.I1) /* All Upper case */
If SubStr(Word(CORE_Disk.I1, 4), 2,1) = 'D'
Then CORE_Disk.I1 = Strip(CORE_Disk.I1,"T")||'\'
end
If Time_Run Then Say 'Sorting files from "'CORE_Dir'" at' Time_Stamp()
SS_In = Pos(CORE_Dir, CORE_Disk.1) + Length(Core_Dir)/* ATH 8/10/92 */
Call RxStemSort "CORE_Disk", "A", SS_In /* ATH 8/10/92 */
If Debug Then Do I1 = 1 to CORE_Disk.0
Say Right(I1,3) Core_Disk.I1
end
Return
/*----------------------------------------------------------------------
* Get the next record from the CORE Source disk list file
* Input: L1 - Pointer to the last record.
* Output: L_Date, L_Time, L_Size, L_Att - From RxTree
* L_Spec - File spec without drive ID i.e. no "W:\"
* L_Path - Full path without drive ID.
* L_Dir - First path in the Filespec.
* L_FN - The file name and ext.
* L_In - The length of the path.
*----------------------------------------------------------------------*/
Get_List_Rec:
Path_OK = 0 /* Reset ATH 8/04/92 */
Do Until Path_OK
Last_L_Spec = L_Spec /* Save last Spec to test sort */
L1 = L1 + 1 /* Next record in the list */
If L1 > CORE_List.0 Then Do
End_Of_List = 1
L_Spec = X2C('FF') || '<-FF' /* Make List High to get Disk. ATH 8/06/92 */
If Debug Then Say 'List' Right(L1, 4) '= "End of List"'
Return
End
Parse Upper Var CORE_List.L1 L_Date L_Time L_Size L_Att x ":\" L_Spec
L_Spec = Strip(L_Spec) /* Remove Trailing blanks */
/* L_Date = Translate(L_Date,"/","-") ATH 11/13/92 */
Parse Var L_Spec L_Dir "\" y /* ATH 11/13/92 */
L_In = lastpos('\', L_Spec) /* Last "\" before FN ATH 11/13/92 */
L_Path = Left(L_Spec, L_In) /* Get Path ATH 11/13/92 */
L_FN = SubStr(L_Spec, L_In+1) /* Get the filename ATH 11/13/92 */
/* Skip the Local and wastebin directories + all Directory Att. */
/* If L_Dir = "WASTEBIN" | L_Dir = "LOCAL" | Substr(L_Att,2,1) = "D" ATH 11/13/92 */
If L_Dir = "WASTEBIN" | L_Dir = "LOCAL" /* ATH 11/13/92 */
Then Path_Ok = 0 /* Get next record from the List */
Else Path_Ok = 1 /* Path ok */
If Last_L_Spec > L_Spec then Do /* Debug code to check sort */
Say 'Warning - List file is not sorted correctly. Index =' L1,
'"'Last_L_Spec'" > "'L_Spec'".'
end
End
If Debug Then Say 'List' Right(L1, 4) '=' ,
Right(L_Date,8) Right(L_Time,6) Right(L_Size,8) L_Spec
If L_Spec = ""
Then Do
Say 'Error in' Input_File 'line' L1'.'
Say CORE_List.L1
Call Exit_RC 2 /* ATH 10/16/92 */
End
Return
/*----------------------------------------------------------------------
* Get the next record from the Local disk file
* Input: D1 - Pointer to the last record.
* Output: D_Date, D_Time, D_Size, D_Att - From RxTree
* D_Spec - File spec without drive ID i.e. no "W:\"
* D_Path - Full path without drive ID.
* D_Dir - First path in the Filespec.
* D_FN - The file name and ext.
* D_In - The length of the path.
*----------------------------------------------------------------------*/
Get_Disk_Rec:
Path_OK = 0 /* Reset ATH 8/04/92 */
Do Until Path_OK
Last_D_Spec = D_Spec /* Save last spec to test the sort */
D1 = D1 + 1 /* Next record in the list */
If D1 > CORE_Disk.0 Then Do
End_Of_File = 1
End_Of_File = 1
D_Spec = X2C('FF') || '<-FF' /* Make Disk High to get List. ATH 8/06/92 */
D_Att = "" /* Reset ATH 11/13/92 */
If Debug Then Say 'Disk' Right(D1, 4) '= "End of File"'
Return
End
Parse Upper Var CORE_Disk.D1 D_Date D_Time D_Size D_Att x ,
Value(CORE_Dir) D_Spec /* Only the common data ATH 8/06/92 */
D_Spec = Strip(D_Spec) /* Remove Trailing blanks */
Parse Var D_Spec D_Dir "\" y /* ATH 11/13/92 */
D_In = lastpos('\', D_Spec) /* Last "\" before FN */
D_Path = Left(D_Spec, D_In) /* Get Path ATH 11/13/92 */
D_FN = SubStr(D_Spec, D_In+1) /* Get the filename */
/* Skip the Local and wastebin directories and Local files. */
If D_Dir = "WASTEBIN" | D_Dir = "LOCAL" |, /* 1st Dir ATH 11/13/92 */
D_FN = "$$$MB$$$.LOG" /* Local Files ATH 8/04/92 */
Then Path_Ok = 0 /* Get next record from the List */
Else Path_Ok = 1 /* Path ok */
If Last_D_Spec > D_Spec then Do /* Debug code to check sort */
Say 'Warning - Disk file is not sorted correctly. Index =' D1,
'"'Last_D_Spec'" > "'D_Spec'".'
end
End
If Debug Then Say 'Disk' Right(D1,4) '=' ,
Right(D_Date,8) Right(D_Time,6) Right(D_Size,8) D_Spec
Return
/*----------------------------------------------------------------------*
* When Equal a file has a different Date, time or size *
*----------------------------------------------------------------------*/
Error_Equal:
/* The Target file will be a different date/time. don't count as err. */
If D_FN = Target_File Then Return /* ATH 8/04/92 */
If Sync_IMAGE /* If Sunc the CORE disk via NFS ATH 8/12/92 */
Then Call Download Rep /* Copy data from Master ATH 8/12/92 */
Else Do /* Show the error ATH 8/12/92 */
Backlevel_Ct = Backlevel_Ct + 1
Fill_Ct = 30 - Length(L_Spec)
If Fill_Ct < 0 then Fill = ""; else Fill = Left(" ",Fill_Ct)
Out_Line = Right(L_Date,8) Right(L_Time,6) Right(L_Size,8) L_Spec ,
Fill"(Wrong Level)"
Call Log_Output
end
Return
/*----------------------------------------------------------------------*
* When low a file is missing locally *
*----------------------------------------------------------------------*/
Error_Low:
If Sync_IMAGE /* If Sunc the CORE disk via NFS ATH 8/12/92 */
Then Call Download New /* Copy data from Master ATH 8/12/92 */
Else Do /* Show the error ATH 8/12/92 */
Missing_Ct = Missing_Ct + 1
Fill_Ct = 30 - Length(L_Spec)
If Fill_Ct < 0 then Fill = ""; else Fill = Left(" ",Fill_Ct)
Out_Line = Right(L_Date,8) Right(L_Time,6) Right(L_Size,8) L_Spec ,
Fill"(Does not Exist)"
Call Log_Output
end
Return
/*----------------------------------------------------------------------*
* When high a file or dir may need be erased locally *
*----------------------------------------------------------------------*/
Error_High:
Log_Msg = "" /* Reset Log Message ATH 11/13/92 */
If Substr(D_Att,2,1) = 'D' /* Is this a directory entry? ATH 11/13/92 */
Then Do /* Yes - Directory ATH 11/13/92 */
L_List = Translate(L_Path, ' ', '\') /* List Path ATH 11/13/92 */
D_List = Translate(D_Spec, ' ', '\') /* Disk Path ATH 11/13/92 */
/* Say 'List Spec =' L_Spec
Say 'List Dir. =' L_List
Say 'Disk Dir. =' D_List */
Do I1 = 1 to Words(D_List) /* Compare directory tree ATH 11/13/92 */
/* Say 'Index' I1 'L_Dir "'Word(L_List, I1)'" D_Dir "'Word(D_list, I1)'"' */
If Word(L_List, I1) <> Word(D_list, I1) /* Same? ATH 11/13/92 */
Then Do /* Queue the directory to be erased. ATH 11/13/92 */
Dir_I = Dir_List.0 + 1 /* + 1 ATH 11/13/92 */
/* Remove the trailing '/' from the directory name */
Dir_List.Dir_I = D_Date D_Time D_Size , /* ATH 11/13/92 */
CORE_Dir || Left(D_Spec, Length(D_Spec)-1) /* 11/13/92 */
Dir_List.0 = Dir_I /* Remember count ATH 11/13/92 */
/* Say 'Queue' Dir_I '=' Dir_List.Dir_I
Say */
Leave I1 /* Exit the loop ATH 11/13/92 */
end
end
end /* ATH 11/13/92 */
Else Do /* No - File ATH 11/13/92 */
Log_Msg = "" /* Reset Log Message ATH 11/13/92 */
If Erase_old /* Should we Erase the file? */
Then Do /* Yes - Erase file */
If Ask_User
Then Do
Say
Call RxSay "Do you want to Erase" CORE_Dir || D_Spec " (Y/N): "
Resp = Translate(RxGetKey())
Say
end
Else Resp = "Y"
If Resp = 'Y'
Then Do
File_Spec = CORE_Dir || D_Spec
If Substr(D_Att,4,1) = "R" /* If Read only flip the bit */
Then Call RxTree File_Spec, 'Temp', 'F', '*****', '***-*'
'Erase "'File_Spec'"'
If RC = 0 Then Log_Msg = "(Erased)"
Else Do
Log_Msg = "(Erase RC =" RC")"
Erase_Ct = Erase_Ct + 1
end
end
end
If Log_Msg = "" Then Do /* If not erased, tell user */
Erase_Ct = Erase_Ct + 1
Log_Msg = "(Should be Erased)"
end
Fill_Ct = 30 - Length(D_Spec)
If Fill_Ct < 0 then Fill = ""; else Fill = Left(" ",Fill_Ct)
Out_Line = Right(D_Date,8) Right(D_Time,6) Right(D_Size,8) D_Spec ,
Fill || Log_Msg
Call Log_Output
end
Return
/*----------------------------------------------------------------------*/
Download: /* ATH 8/12/92 */
Parse Arg Flag . /* Get the Replace Flag ATH 8/12/92 */
/* Remove code ... ATH 11/13/92
L_In = lastpos('\', L_Spec) /* Split path & filename ATH 8/12/92 */
L_Path = Left(L_Spec,L_In) /* Full Path if any ATH 11/13/92 */
L_FN = Substr(L_Spec,L_In+1) /* Filename.Ext ATH 8/12/92 */
... End of removed code ATH 11/13/92 */
Temp_Spec = CORE_dir||L_Path||Temp_File /* ATH 11/13/92 */
Master_File = Master_CORE||L_Spec /* ATH 8/12/92 */
L_File_Spec = CORE_Dir || L_Spec /* ATH 9/25/92 */
Retry_Copy_Ct = 0 /* Reset the retry count ATH 9/25/92 */
Do Until Retry_Copy = 0 /* Loop if the flag is set ATH 8/12/92 */
Retry_Copy = 0 /* Reset the loop flag ATH 8/12/92 */
"ECHO NO | XCOPY" Master_File Temp_Spec '>nul 2>&1' /* 10/29/92 */
XRC = RC /* Save the XCopy RC ATH 10/06/92 */
If XRC = 0 /* Any errors from XCopy? ATH 8/12/92 */
Then Do /* No - Then rename the temp file. ATH 8/12/92 */
/* Check the Date time and size of the copied file to see if */
/* it realy did copy ok. ATH 10/06/92 */
Call RxTree Temp_Spec, 'Temp', 'F' /* Did it copy ATH 10/06/92 */
If Temp.0 <> 1 Then XRC = 98 /* No - error ATH 10/06/92 */
Else Do /* Yes- check Date time and size. ATH 10/06/92 */
Parse Upper Var Temp.1 T_Date T_Time T_Size T_Att T_Spec
If T_Date <> L_Date | T_Time <> L_Time | T_Size <> L_Size
Then XRC = 99 /* Error if D/T/Size not = ATH 10/06/92 */
end
end /* ATH 8/12/92 */
/* XRC will be the RC from XEdit or Error 98 or 99 from above. */
If XRC = 0 & Flag = Rep /* Replacing a file? ATH 10/16/92 */
Then Do /* Yes - Erase the old one. ATH 10/06/92 */
If Substr(D_Att,4,1) = "R" /* If Read only flip the bit */
Then Call RxTree L_File_Spec, 'Temp', 'F', '*****', '***-*'
'Erase' L_File_Spec /* Erase the old file ATH 10/16/92 */
If RC <> 0 Then do /* If Error Erasing file ... ATH 10/16/92 */
ERC = RC /* then save the Return Code & ... ATH 10/16/92 */
XRC = 97 /* set the Replace Error Code. ATH 10/16/92 */
If Net_Close /* If NetClose option ... ATH 10/16/92 */
Then Do /* then force the file closed. ATH 10/16/92 */
NetClose NC_Path||L_Spec /* Close file. ATH 10/16/92 */
'Erase' L_File_Spec /* Erase again. ATH 10/16/92 */
If RC = 0 then XRC = 0 /* Reset RC if ok. ATH 10/16/92 */
end /* ATH 10/16/92 */
end /* ATH 10/16/92 */
end /* ATH 8/12/92 */
If XRC = 0 /* XRC may be reset from the Erase above ATH 10/16/92 */
Then Do /* If no Errors at all from above. ATH 10/16/92 */
'Rename' Temp_Spec L_FN /* Back to Original Name ATH 8/12/92 */
XRC = RC /* Save the return Code ATH 10/16/92 */
end /* ATH 10/16/92 */
If XRC = 0 /* XRC may be reset from the Rename above ATH 10/16/92 */
Then Do /* If no Errors at all from above. ATH 10/16/92 */
Download_Msg = '(Copied)' /* Log change ATH 10/16/92 */
Copied_Ct = Copied_Ct + 1 /* Count copies ATH 10/16/92 */
end /* ATH 8/12/92 */
Else Do /* If any Errors at all from above ATH 10/16/92 */
If RxFileExist(Temp_Spec) /* If file exists ATH 8/12/92 */
Then 'Erase' Temp_Spec /* erase it. ATH 8/12/92 */
If L_In > 0 /* Is the length of path > 0? ATH 8/12/92 */
Then do /* If there is a path ATH 8/12/92 */
Test_Path = CORE_dir||left(L_Path, L_In-1)/* ATH 11/13/92 */
If \RxDirExist(Test_Path) /* Any Dir? ATH 8/12/92 */
Then Do /* No, Make one ATH 8/12/92 */
RC = RxMkDir(Test_Path) /* Make the dir ATH 8/12/92 */
If RC = 0 /* If ok set the flag ATH 8/12/92 */
Then Retry_Copy = 1 /* Retry copy ATH 8/12/92 */
end /* ATH 8/12/92 */
end /* ATH 9/25/92 */
/* Retry_Copy will be 0 unless a directory was created above. */
If Retry_Copy = 0 /* Count error if no retry ATH 8/12/92 */
Then Do /* Retry the operation ATH 9/25/92 */
If Retry_Copy_Ct < Retry_Count /* ATH 9/25/92 */
Then Do /* ATH 9/25/92 */
Retry_Copy_Ct = Retry_Copy_Ct + 1 /* ATH 9/25/92 */
Retry_Copy = 1 /* Retry the copy ATH 9/25/92 */
Say ' Error RC = "'XRC'". Retrying "'L_File_Spec'".'
end
Else Do /* ATH 9/25/92 */
Download_Ct = Download_Ct + 1 /* ATH 9/25/92 */
Select /* Set the error message ATH 10/06/92 */
When XRC = 97
Then Download_Msg = '(Replace RC =' ERC')'
When XRC = 98
Then Download_Msg = '(Not Copied)'
When XRC = 99
Then Download_Msg = '(Copied Level Wrong)'
Otherwise Download_Msg = '(XCopy RC =' XRC')'
end /* ATH 10/16/92 */
end /* ATH 10/16/92 */
end /* ATH 10/16/92 */
end /* ATH 10/16/92 */
end /* ATH 10/16/92 */
Fill_Ct = 30 - Length(L_Spec) /* ATH 8/12/92 */
If Fill_Ct < 0 then Fill = ""; else Fill = Left(" ",Fill_Ct)
Out_Line = Right(L_Date,8) Right(L_Time,6) Right(L_Size,8) L_Spec ,
Fill || Download_Msg /* ATH 8/12/92 */
Call Log_Output /* ATH 8/12/92 */
Return /* ATH 8/12/92 */
/*----------------------------------------------------------------------*/
Log_Output:
Say Out_Line
Call LineOut Output_File, Out_Line
If Result = 1 then Signal Write_Err
Return
/*----------------------------------------------------------------------*/
Set_Msg:
Send_Msg = 1
Parse var etc Msg_Name etc
If Msg_Name = "" Then Do
Say "Name required after the Message option."
Call Exit_RC 1 /* ATH 10/16/92 */
End
Return
/*----------------------------------------------------------------------*/
Time_Stamp:
TS_Last = TS_This
TS_This = Time('E')
TS_Diff = (TS_This - TS_last)
Return Time() '('Format(TS_Diff,4,2) Format(TS_This,4,2)')'
/*----------------------------------------------------------------------*/
Read_Err:
Say "Error Reading the Input file."
Call Exit_RC 2 /* ATH 10/16/92 */
/*----------------------------------------------------------------------*/
Write_Err:
Say "Error Writing the Output file."
Call Exit_RC 2 /* ATH 10/16/92 */
/*----------------------------------------------------------------------*/
Erase_File:
Parse Arg Erase_File
If Stream(Erase_File,'c','query exists') <> ""
Then "Erase" Erase_File /* Erase the file if it exists. */
Return
/*----------------------------------------------------------------------*/
Exit_RC: /* ATH 10/16/92 */
Parse Var Ret_Code . /* ATH 10/16/92 */
If Send_Msg & Ret_Code <> 0 Then Do /* Notify on Error ATH 10/16/92 */
If Error_Ct <> 1 Then s = 's'; else s = '' /* ATH 10/16/92 */
/* 'Call W:\Notify.Cmd .' CMD_Name Ret_Code Msg_Name ,ATH 10/16/92 */
/* Error_Ct 'Error's' found in the' Core_Dir 'directory.' 10/16/92 */
'Call Notify . ' CMD_Name Ret_Code 'CORE' Error_Ct ,/* DSK 10/16/92 */
'Error's' found in the' Core_Dir 'directory.' /* DSK 10/16/92 */
end /* ATH 10/16/92 */
Exit Ret_Code /* ATH 10/16/92 */
/*----------------------------------------------------------------------*/
Help:
cls
Say ''
Say 'VerImage will read the' Target_File 'and verify that all of the files listed'
Say 'in it are on the NetDoor disk. Any inconsistencies will be logged into the'
Say Output_File 'file in the current directory. '
Say ''
Say 'VERIMAGE ─ NetDoorDir ─┬─────────────────┬───┬───────────────────┬──┤'
Say ' ├ /New ───────────┤ ├ /Sync Source_Dir ─┤ '
Say ' ├ /Erase ─────────┤ ├ /NETClose path ───┤ '
Say ' ├ /Yes ───────────┤ ├ /Retry nn ────────┤ '
Say ' ├ /LIst ──────────┤ ├ /LOg file_spec ───┤ '
Say ' ├ /Message name ──┤ └──────────────────┘ '
Say ' └────────────────┘ '
Say ''
Say 'Where: "NetDoorDir" is the path to the local NetDoor disk to be verified.'
Say ' For example: "W:\" or "D:\COUIMAGE\"'
Say ''
Say 'Files found in the "Local" or "WasteBin" directories will be skipped as these'
Say 'files are normally unique to the local site. When a file in the "NetDoorDir"'
Say 'is replaced or erased and the Read only bit is on it will be turned off and '
Say 'turned back on for the replacement file.'
Say ''
If \Abbrev("HELP", CORE_Dir, 1)
Then Do
Say ' (Enter "'CMD_Name 'Help" for more details and examples.)'
Exit;
End
Else Do
Call CharOut ,' (Press the "Enter" key to continue)'
A = CharIn(,,2)
End
"CLS"
Say 'Options: (Characters in upper case are the minimum required.)'
Say ''
Say ' /New Will erase the "'Output_File'" file before running the program.'
Say ' /Erase Will remove empty directories and ask the user if he wants to '
Say ' erase any files found in the "NetDoorDir" that are not listed in'
Say ' the "'Target_File'" file.'
Say ' /Yes Will not ask for verification when erasing files.'
Say ' /Sync Source_Dir Will use the Source_Dir as the master NetDoor disk and '
Say ' synchronize the local NetDoor to it. Normally the Source_Dir'
Say ' is the "D:\World" directory on the NFS mounted "YKTUP01" disk'
Say ' from Yorktown. (See NFS Note below)'
Say ' /Retry nn The retry count for copy errors when synchronizing.'
Say ' nn = "'Retry_Count'" by default.'
Say ' /NETClose path Will call the NetClose command to close locked file'
Say ' when using the "/Sync" option. The "path" must be in the form'
Say ' required by the NetClose command. i.e. "\\Server\Alias\Path"'
Say ' or "d:\Path" where "d:" is a network drive, NOT a LOCAL drive.'
Say ' /Message name Will use the Notify command to send an error message'
Say ' to the Notify name specified by Name. (See Notify.Cmd)'
Say ' /LIst Create a "'Target_File'" file on the "Source_Dir" from the'
Say ' files currently on the disk. Used on the NetDoor Master only. '
Say ' /LOg file_spec Will change the name of the log file "'Output_File'"'
Say ' to the name specified by "file_spec".'
Say ''
Call CharOut ,' (Press the "Enter" key to continue)'
A = CharIn(,,2)
"CLS"
Say 'NFS Note: If you are in a different time zone then Yorktown than the "NFSC" '
Say ' Daemon will adjust the date and time of files copied to the local '
Say ' date and time. To get around this set the "TZ" environmental '
Say ' variable to the Yorktown time zone before starting "NFSC". Then '
Say ' set the variable back to your local time. '
Say ''
Say ' The following example will start the NFS Client with the Yorktown time zone,'
Say ' mount the master NetDoor disk and run VerImage to synchronize the local NetDoor'
Say ' disk with a master isk.'
Say ''
Say ' "SET TZ=EST5EDT" (East cost time zone.)'
Say ' "NFSC" (Start the NFS Client.)'
Say ' "SET TZ=PST8PDT" (If you are on the west cost.)'
Say ' "Mount -u2 -g2 X: YKTUP01.watson.ibm.com D:\World" '
Say ' (You must be authorized to Mount the NetDoor source disk.)'
Say ' "VerImage W:\ /Sync X:\ /NETClose W:\ /Erase /Yes"'
Say ''
Say ' To verify your Local NetDoor system and be prompted to erase any old file that '
Say ' are no longer needed, enter the following command.'
Say ''
Say ' "VerImage W:\ /Erase"'
Say ''
Call CharOut ,' (Press the "Enter" key to continue)'
A = CharIn(,,2)
"CLS"
Say 'Sample VerImage.Log file entries and error conditions:'
Say ''
Say '11/14/91 9:31A 268 ADMTOOLS\SYNCSERV.CMD (Wrong Level)'
Say ' The file listed above (from "'Target_File'") has a different date'
Say ' time or size then the file found in the local "NetDoorDir".'
Say ' Use the "/Sync" option to download the file.'
Say ''
Say ' 4/03/92 2:59P 2294 TCPIPR0\BIN\XINIT.CMD (Does not Exist)'
Say ' The file listed above (from "'Target_File'") was not found in the'
Say ' local "NetDoorDir". Use the "/Sync" option to download the file.'
Say ''
Say ' 3/10/92 4:55P 88 ADMTOOLS\REBOOT\NOTIFY.LOG (Should be Erased)'
Say ' The file listed above was found in the local "NetDoorDir" but is not'
Say ' listed in the "'Target_File'" file. Use the "/Erase" option to'
Say ' erase the file from the local "NetDoorDir".'
Say ''
Say ' 3/10/92 4:55P 88 ADMTOOLS\REBOOT\NOTIFY.LOG (Erased)'
Say ' The file listed above was erased from the local "NetDoorDir".'
Say ''
Say ' 3/10/92 4:55P 88 ADMTOOLS\REBOOT\NOTIFY.LOG (Erase RC = 1 )'
Say ' When attempting to erase the file listed above a non 0 return code'
Say ' was returned by the erase command and the file was not erased.'
Say ''
Call CharOut ,' (Press the "Enter" key to continue)'
A = CharIn(,,2)
"CLS"
Say 'Sample VerImage.Log file entries and error conditions for directories:'
Say ''
Say ' 7/21/92 1:42P Dir W:\ADMTOOLS\UTIL (Should be removed)'
Say ' The directory listed above is empty and should be removed from the'
Say ' local "NetDoor". Use the "/Erase" option to remove the directory'
Say ' from the local "NetDoorDir".'
Say ''
Say ' 7/21/92 1:42P Dir W:\ADMTOOLS\UTIL (Removed)'
Say ' The directory listed above was removed from the local "NetDoorDir".'
Say ''
Say ' 7/21/92 1:42P Dir W:\ADMTOOLS\UTIL (RmDir RC = 1 )'
Say ' When attempting to remove the directory listed above a non 0 return'
Say ' code was returned by the "RmDir" command and the directory was not'
Say ' removed.'
Say ''
Call CharOut ,' (Press the "Enter" key to continue)'
A = CharIn(,,2)
"CLS"
Say 'Sample VerImage.Log file entries and error conditions using the "/Sync" Option:'
Say ''
Say ' 8/06/92 11:19A 7122 ADMTOOLS\VERIMAGE.CMD (Copied)'
Say ' The file listed above was successfully copied (downloaded) from the'
Say ' "Source_Dir" specified on the "/Sync" option to the local "NetDoorDir".'
Say ''
Say ' 6/04/91 1:31P 0 PMCAL\TIMEXEC.RMD (Not Copied)'
Say ' XCopy returned a return code of 0 but the file was not copied.'
Say ''
Say ' 6/04/91 1:31P 0 PMCAL\TIMEXEC.RMD (Copied Level Wrong)'
Say ' XCopy returned a return code of 0 but the copied file had a'
Say ' different Date, Time or Size then the file listed above.'
Say ''
Say ' 8/06/92 11:16A 7122 ADMTOOLS\VERIMAGE.CMD (XCopy RC = 1)'
Say ' A non 0 return code was returned by the "XCopy" command when'
Say ' attempting to downloaded the file listed above.'
Say ''
Say ' 3/20/92 1:57P 85504 DLL\RXUTILS.DLL (Replace RC = 1)'
Say ' The "Erase" command returned the non 0 return code a when attempting'
Say ' to replace the file listed above. The original file may be locked.'
Say ' Try using the "/NETClose" option to force the file closed.'
Say ''
Call CharOut ,' (Press the "Enter" key to continue)'
A = CharIn(,,2)
"CLS"
Say ''
Say ' For all error conditions using the "/Sync" option, the original file will'
Say ' remain unchanged in the local "NetDoorDir". These errors may be caused by:'
Say
Say ' * A transmission error when using the TCP/IP Network File System.'
Say
Say ' * The file on the local "NetDoorDir" may be locked. Try using the "/NETClose"'
Say ' option to force the file closed.'
Say
Say ' * The "/NETClose" option specified a local drive, not a network drive.'
Say
Say ' * The file on the local "NetDoorDir" is locked by a local application'
Say ' running on the server. The application locking the file must release'
Say ' it before it can be replaced. Try stopping the application on the server.'
Say
Say ' * A file was replace on the "Source_Dir" after the "'Target_File'" file'
Say ' was updated.'
Exit