/********************** PALS-IT REXX PROLOGUE ********************************/
/*                                                                           */
/* Testcase Name:     ITLPEER.CMD                                            */
/*                                                                           */
/* Descriptive Name:  OS/2 PEER  EXERCISER                                   */
/*                                                                           */
/* FUNCTION TESTED:   Remote file access                                     */
/*                                                                           */
/* TESTCASE OBJECTIVE:                                                       */
/*    DESCRIPTION:                                                           */
/*        LAN Distance Dial to Connection Server IT01S01                     */
/*        Get network resource (Net use the X: DRIVE), copy different files. */
/*        to the local DRIVE.  Compare local files to remote files.          */
/*        Then erase the files. There are delays between copies.             */
/*        This test loops continuously until control C is entered            */
/*    END_OF_DESCRIPTION                                                     */
/*                                                                           */
/*    TESTABLE ITEMS:                                                        */
/*        OS/2 peer (or LAN Requester with peer services)                    */
/*                                                                           */
/* DEPENDENCIES:                                                             */
/*                                                                           */
/* MANUAL INTERVENTION                                                       */
/*    None                                                                   */
/*                                                                           */
/*    PREREQUISITES:                                                         */
/*                                                                           */
/*                                                                           */
/*    Input Parameters:                                                      */
/*                                                                           */
/*        - Number of loops to run, Target to use, time between loops        */
/*                                                                           */
/*    Outputs:                                                               */
/*        - RC= 0 if successful      RC=8 if failed                          */
/*                                                                           */
/*    SPECIAL NOTES:                                                         */
/*                                                                           */
/*        - None.                                                            */
/*                                                                           */
/* RESTRICTIONS:                                                             */
/*    none                                                                   */
/*                                                                           */
/* CHANGE ACTIVITY:                                                          */
/*   Ver  Date      NAME         Comments                                    */
/*   1.0  8/05/93  R.Bassemir    Initial release copied from ITLLS56.CMD     */
/*   1.1  8/06/93  R.Bassemir    Updated with time stamp message on errors   */
/*   1.0  10/11/95 R.Bassemir    Updated for use with OS/2 peer              */
/*   1.1  02/17/97 R.Bassemir    Updated for use with self test kit          */
/*   1.3  5/23/97  R.Bassemir    Changed the logfile naming convention       */
/*   1.4  5/27/97  R.Bassemir    Write log file back to D01, added parm      */
/*                               for setting the number of loopcnt            */
/*   1.5  6/02/97  R.Bassemir    Erased logfile on D01 before starting       */
/*   1.6  6/12/97  S.Hudson      Added the use of nextfree DRIVE, added the  */
/*                               detection of the boot DRIVE, added remote   */
/*                               logging of results, added history file      */
/*                                                                           */
/*        7/03/97  S. Hudson     Change to use OS2DRV instead of hardcode c  */
/*        7/10/97  S. Hudson     Change to use subdir on local system for    */
/*                               copy, compare, and erase of test data files */
/*        7/15/97  S. Hudson     Change to use common functions for methods  */
/*                               of creating history,log files, extracting   */
/*                               local system names, duration times.         */
/*        7/25/97  S. Hudson     Add 16K file to copy list of files          */
/*        7/25/97  S. Hudson     Change to add xcopy of all .MB files        */
/*        8/6/97   S. Hudson     Add COMP for xcopy of files to-from domain  */
/*        8/16/97  S. Hudson     Add 3sec sleep aft copy before net use /d   */
/*                               for files to be released before dropping net*/
/*                                                                           */
/*****************************-END PROLOGUE-**********************************/
arg  loopcnt  peername  sleeptime  .
TRACE  off

/**************************************************************************/
/* USE OS2 ENVIRONMENT VARIABLE COMSPEC= TO FIND OS/2 BOOT DRIVE.         */
/**************************************************************************/
cmspec = value('COMSPEC',,'OS2ENVIRONMENT');
os2drv = left(cmspec,1)||':'

if loopcnt = '?' then signal HELP

if loopcnt = '' then loopcnt = 50

if peername = '' then peername = IT01R01

if sleeptime = '' then sleeptime = 5

/*****************************************************************************/
/*****************************************************************************/
CALL RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
CALL RxFuncAdd 'SysFileSearch','RexxUtil','SysFileSearch'
CALL SysLoadFuncs

/***************** determine NETBIOS name **local system*************/
CALL SysFileSearch 'Computername',os2drv'\ibmlan\ibmlan.ini','file.'
localname = strip(subword(file.1,3,1))

/***************** define the log file and history file *************/
logfile = os2drv'\'||substr(localname,5,3)'logs\itlpeer.'||substr(localname,5,3)
histfile = os2drv'\'||substr(localname,5,3)'logs\itlpeer.'||substr(localname,5,3)'.history'

/***************** initialize a history file **************************/
res = lineout(histfile, '***** 'time() date()' ITLPEER History *****')
res = lineout(histfile)

/***************** copy existing file to history ********************/
'copy 'histfile'+'logfile' 'histfile
'erase 'logfile

/**************** start a new log file *****************************/
res = lineout(logfile, '***** 'time() date()' ITLPEER STARTING *****')
res = lineout(logfile)


start_time = date('u') time('c')

/******* determine the next available DRIVE for a net use ******/
ndrive = nextfree()
if ndrive = 0 then
   do
      say '- There are NO free DRIVES for the NET USE '
      say '           *** This test will end now.'
      exit
   end /* do */

'net use 'ndrive' \\'peername'\R01LOGS'     /* get network resource          */
'erase 'ndrive||substr(logfile,12,11)       /* erase logfile on R01 if there */
'net use 'ndrive' /D'                       /* drop the network resource     */

/********** set up data files to use small *K.DAT files *****************/
datafile1 = '1k.dat'
datafile2 = '2k.dat'
datafile3 = '4k.dat'
datafile4 = '8k.dat'
datafile5 = '16k.dat'

count = 1
xx =time('e')           /* this initializes elapsed timer for testcase */

/***************  start the copy and compares  ********************/

DO while count < loopcnt
     Call get_drive
     Call copy_file datafile1
     Call copy_file datafile2
     Call copy_file datafile3
     Call copy_file datafile4
     Call copy_file datafile5
     Call xcopy_files
  Call drop_drive
END

/****** run completed successfully, copy log file back to D01 ******/
res = lineout(logfile, '***** 'time() date()' ITLPEER Completed successfully *****')
res = lineout(logfile)

'NET USE 'ndrive' \\'peername'\R01LOGS'         /* get network resource      */
'copy 'logfile' 'ndrive'*.*'                    /* copy log to R01           */

CALL SysSleep 3

'NET USE 'ndrive' /DELETE'                      /* drop the network resource */

exit
/* ************************************************************************* */
/* NORMAL EXIT POINT WHEN TESTCASE COMPLETES OK                              */
/* ************************************************************************* */



/************* get the DRIVE ***************************************/
GET_DRIVE:
'NET USE 'ndrive' \\'peername'\os2peer'     /* get network resource        */
 IF (RC \= 0 & RC \= 2) then do             /* exit if the NET USE failed  */
   SAY 'THE USE OF THE NETWORK RESOURCE FAILED. RETURN CODE WAS: ' RC
   DATETIME = DATE() TIME()                  /* set time and date           */
   SAY DATETIME                              /* output date and time        */
    CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                /* drop the network resource   */
   errorwith = netuse
   call bad_exit errorwith
 END

'MD 'ndrive'\'||localname             /* make the test dir on network DRIVE */

'MD 'os2drv'\itlutil\peertest'         /* make the test dir on local   DRIVE */
return


/************* copy the file ***************************************/
COPY_FILE:
parse upper arg file_name
file_name = strip(file_name)

etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)

if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'

say 'ITLPEER> CURRENT PASS: 'count' START: 'start_time' ELP: 'etimestamp

'COPY 'ndrive'\'||file_name os2drv||'\ITLUTIL\PEERTEST' /* copy to local DRIVE */
IF RC \= 0 then do                                    /* exit if copy failed */
   SAY 'THE FIRST COPY OF 'file_name' FAILED.  RETURN CODE WAS: ' RC
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstcopy
   call bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\'||file_name os2drv||'\ITLUTIL\PEERTEST\'||file_name' < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE FIRST COMP OF 'file_name 'FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstcomp
   call bad_exit errorwith                         /* post error and exit    */
 END

etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)

if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'

say 'ITLPEER> CURRENT PASS: 'count' START: 'start_time' ELP: 'etimestamp
SAY 'ITLPEER> Sleeping for 'sleeptime' seconds after copy and compare.'
call SysSleep sleeptime

'COPY 'os2drv||'\ITLUTIL\PEERTEST\'||file_name ''ndrive'\'||localname
IF RC \= 0 then do                                 /* exit if copy failed    */
   SAY 'THE SECOND COPY OF 'file_name' FAILED.  RETURN CODE WAS: ' RC
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondcopy
   call bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\'||file_name ''ndrive'\'||localname||'\'||file_name' < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE SECOND COMP OF 'file_name 'FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondcomp
   call bad_exit errorwith                         /* post error and exit    */
 END

etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)

if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'

say 'ITLPEER> CURRENT PASS: 'count' START: 'start_time' ELP: 'etimestamp
SAY 'ITLPEER> Sleeping for 'sleeptime' seconds after copy and compare.'
call SysSleep sleeptime

'ERASE 'ndrive'\'||localname||'\'file_name
'ERASE 'os2drv||'\ITLUTIL\PEERTEST\'||file_name

return


/************* copy the file ***************************************/
XCOPY_FILES:

etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)

if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'

say 'ITLPEER> CURRENT PASS: 'count' START: 'start_time' ELP: 'etimestamp

'XCOPY 'ndrive'\*K.DAT 'os2drv||'\ITLUTIL\PEERTEST'   /* copy to local DRIVE */
IF RC \= 0 then do                                    /* exit if copy failed */
   SAY 'THE FIRST COPY OF 'file_name' FAILED.  RETURN CODE WAS: ' RC
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstxcopy
   CALL bad_exit errorwith                         /* post error and exit    */
 END


'COMP 'ndrive'\1K.DAT 'os2drv||'\ITLUTIL\PEERTEST\1K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE FIRST XCOPY COMP OF 1K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstxcomp1
   CALL bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\2K.DAT 'os2drv||'\ITLUTIL\PEERTEST\2K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE FIRST XCOPY COMP OF 2K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstxcomp2
   CALL bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\4K.DAT 'os2drv||'\ITLUTIL\PEERTEST\4K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE FIRST XCOPY COMP OF 4K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstxcomp3
   CALL bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\8K.DAT 'os2drv||'\ITLUTIL\PEERTEST\8K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE FIRST XCOPY COMP OF 8K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstxcomp4
   CALL bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\16K.DAT 'os2drv||'\ITLUTIL\PEERTEST\16K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE FIRST XCOPY COMP OF 16K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = firstxcomp5
   CALL bad_exit errorwith                         /* post error and exit    */
 END


etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)


if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'


say 'ITLPEER> CURRENT PASS: 'count' START: 'start_time' ELP: 'etimestamp
SAY 'ITLPEER> Sleeping for 'sleeptime' seconds after xcopy and compares.'
call SysSleep sleeptime


'XCOPY 'os2drv||'\ITLUTIL\PEERTEST\*K.DAT 'ndrive'\'||localname
IF RC \= 0 then do                                 /* exit if copy failed    */
   SAY 'THE SECOND COPY OF 'file_name' FAILED.  RETURN CODE WAS: ' RC
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondxcopy
   call bad_exit errorwith                         /* post error and exit    */
 END


'COMP 'ndrive'\1K.DAT 'ndrive'\'||localname||'\1K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE SECOND XCOPY COMP OF 1K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondxcomp1
   call bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\2K.DAT 'ndrive'\'||localname||'\2K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE SECOND XCOPY COMP OF 2K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   CALL SysSleep 3
   errorwith = secondxcomp2
   call bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\4K.DAT 'ndrive'\'||localname||'\4K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE SECOND XCOPY COMP OF 4K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondxcomp3
   call bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\8K.DAT 'ndrive'\'||localname||'\8K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE SECOND XCOPY COMP OF 8K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondxcomp4
   call bad_exit errorwith                         /* post error and exit    */
 END

'COMP 'ndrive'\16K.DAT 'ndrive'\'||localname||'\16K.DAT < 'os2drv||'\ITLUTIL\COMP.RSP'
IF RC <> 0 then do                                 /* exit if compare failed */
   SAY 'THE SECOND XCOPY COMP OF 16K.DAT FAILED.'
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   CALL SysSleep 3
   'NET USE 'ndrive' /DELETE'                      /* drop network resource  */
   errorwith = secondxcomp5
   call bad_exit errorwith                         /* post error and exit    */
 END


etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)


if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'


say 'ITLPEER> CURRENT PASS: 'count' START: 'start_time' ELP: 'etimestamp
SAY 'ITLPEER> Sleeping for 'sleeptime' seconds after xcopy and compares.'
call SysSleep sleeptime


'ERASE 'ndrive'\'||localname||'\*K.DAT <yes.in'
'ERASE 'os2drv||'\ITLUTIL\PEERTEST\*K.DAT <yes.in'


return



/***************** drop the network DRIVE  *********************************/
DROP_DRIVE:
CALL SysSleep 3
'NET USE 'ndrive' /DELETE'                      /* drop the network resource */
IF RC \= 0 then do                              /* exit if the drop  failed  */
   SAY 'THE DELETE OF THE NETWORK RESOURCE FAILED. RETURN CODE WAS: ' RC
   DATETIME = DATE() TIME()                        /* set time and date      */
   SAY DATETIME                                    /* output date and time   */
   errorwith = dropdrive
   call bad_exit errorwith                         /* post error and exit    */
 END

etime = time('e')
emin  = trunc(etime / 60,2)
ehrs  = trunc(emin  / 60,2)

if ehrs < 1 then etimestamp = emin' MIN'
  else etimestamp = ehrs' HRS'

fmsg = 'ITLPEER> COMPLETED PASS: 'count' START: 'start_time' ELP: 'etimestamp
res = lineout(logfile, fmsg)
res = lineout(logfile)

SAY fmsg
SAY 'TILPEER> Sleeping for 'sleeptime' seconds after copy.'
call SysSleep sleeptime

count = count + 1

return

/************ error exit *******************************************/
BAD_EXIT:
parse arg cause

if cause = netuse then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on a net use to domroot *****')
  res = lineout(logfile)
end

if cause = firstcopy then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on first copy *****')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstcomp then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on first compare *****')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondcopy then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on second copy *****')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondcomp then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on second compare *****')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstxcopy then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on first xcopy *****')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondxcopy then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on second xcopy *****')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstxcomp1 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 1K.DAT from first xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstxcomp2 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 2K.DAT from first xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstxcomp3 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 4K.DAT from first xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstxcomp4 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 8K.DAT from first xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = firstxcomp5 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 16K.DAT from first xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondxcomp1 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 1K.DAT from second xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondxcomp2 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 2K.DAT from second xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondxcomp3 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 4K.DAT from second xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondxcomp4 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 8K.DAT from second xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end

if cause = secondxcomp5 then do
  res = lineout(logfile, '***** 'time() date()' ITLLS56 Failed compare of 16K.DAT from second xcopy***')
  res = lineout(logfile)
  'NET USE 'ndrive' \\'peername'\R01LOGS'     /* get network resource        */
  'copy 'logfile' 'ndrive'*.* '
  CALL SysSleep 3
  'NET USE 'ndrive' /delete'                  /* drop the network resource  */
end


if cause = dropdrive then do
  res = lineout(logfile, '***** 'time() date()' ITLPEER Failed on net use /d     *****')
  res = lineout(logfile)
end


EXIT
/* ************************************************************************* */
/* ERROR EXIT POINT WHEN TESTCASE FAILS - CAUSE POSTED IN LOGFILE            */
/* ************************************************************************* */


/************ help menu ********************************************/
HELP:
say ' '
say 'This command will copy and compare files from the domain controller'
say 'The syntax is: '
say '               ITLPEER count target sleeptime'
say 'Where: '
say '      loopcnt   = number of iterations you want the test to run'
say '                 (the default 50 iterations)'
say ' '
say '      peername  =  the name of the peer workstation (default is IT01R01)'
say ' '
say '      sleeptime = the time in seconds between loops (default is 5 seconds)'
say ' '
say 'Notes: -These parameters are position dependent. '
say '       -If you want to specify a different sleeptime then you must also'
say '        specify a count and target'
exit
