home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / dswkly.cmd < prev    next >
OS/2 REXX Batch file  |  1994-06-20  |  3KB  |  125 lines

  1. /******************************************************************************
  2. * Module:   DSWkly.cmd
  3. * Desc:     This does a (weekly) full DualStor backup of the list of drives
  4. * Inputs:   On the command line, specify a space separated list of drives to
  5. *            be backed up to the same tape; i.e.
  6. *
  7. *            DSWkly c d e
  8. *
  9. *            will backup drives c:, d:, and e: to the same tape(s)
  10. * Outputs:  Disks are backed up
  11. * Errors:   
  12. ******************************************************************************/
  13.  
  14. /*  Bring in the OS/2 function library   */
  15. Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs';
  16. Call SysLoadFuncs;
  17.  
  18. /* trace ?I */
  19.  
  20. ?low = 'C'   /* lowest disk mode letter */
  21. ?hi  = 'Z'   /* highest disk mode letter*/
  22.  
  23. /* Get the disk letter(s).  Make them upper case while we're at it */
  24. Parse Upper Arg ?disklist
  25.  
  26. /* Put them into a compound symbol */
  27. ?count = 0
  28. ?disks = ""
  29. Do Until ?disklist = ""
  30.     /* Get the next disk letter */
  31.     Parse Var ?disklist ?drive.?count ?disklist
  32.     ?drive.?count = Left(?drive.?count, 1)
  33.     ?disks = ?disks'-'?drive.?count
  34.     If ?drive.?count < ?low | ?drive.?count > ?hi Then
  35.         Signal Err1  /* check disk arg */
  36.     ?count = ?count + 1
  37. End
  38.  
  39. /* Retension the tape */
  40. ?backup_job = '!util /w cn /r'
  41. Call DoAJob ?backup_job
  42.  
  43. /* Init the tape */
  44. ?backup_job = '!init /w cn /i'
  45. Call DoAJob ?backup_job
  46.  
  47. /* Set the tape to unused */
  48. ?backup_job = '!util /w cn /u'
  49. Call DoAJob ?backup_job
  50.  
  51. /* Name the tape */
  52. ?backup_job = '!util /w cn /n "Disk'?disks'-Larry Waibel Backup"'
  53. Call DoAJob ?backup_job
  54.  
  55. /* Make up the backup .TPF command line    */
  56. ?backup_job = "!backup /m /w cnso"
  57. /* Now loop through the letters, backing them onto the same tape */
  58. ?current = 0
  59. Do While ?current < ?count
  60.     ?backup_job = ?backup_job" /b rhs /c 2 /e f /g",
  61.                 " /n Weekly"?drive.?current" /q /v /s "?drive.?current":\*.*"
  62.     ?current = ?current + 1
  63. End
  64.  
  65. /* Now do the backup */
  66. Call DoAJob ?backup_job
  67.  
  68. Exit
  69.  
  70.  /* $Page */
  71. /******************************************************************************
  72. * Module:   DoAJob
  73. * Desc:     This turns the job line into a .tpf file and executes it
  74. * Inputs:   The job line to be executed
  75. * Outputs:  None
  76. * Errors:   
  77. ******************************************************************************/
  78. DoAJob:
  79.  
  80. ?job = ARG(1)
  81.  
  82. /* Erase old file   */
  83. rc = SysFileDelete('$WORK$.TPF')
  84. If rc > 2 Then Signal Err2
  85.  
  86. Say "Doing job="?job       /* Remove this at some point   */
  87.  
  88. /*Return*/
  89.  
  90. rc = Lineout('$WORK$.TPF', ?job, 1)  /* Write the file  */
  91. If rc \= 0 Then
  92.     Signal Err3   /* Error writing the file  */
  93.  
  94. rc = Lineout('$WORK$.TPF')  /* Close the file  */
  95. If rc \= 0 Then
  96.     Signal Err3  /* error closing the file  */
  97.  
  98. /* Execute the job   */
  99. 'Dualstrp .\$WORK$'
  100. If rc \= 0 ,
  101.     Then Do
  102.         Say "*** JOB FOR '"?disk"' COMPLETED WITH ERROR OF "rc" ***"
  103.         Pause
  104.         Exit rc
  105.     End
  106.  
  107. Return
  108.  
  109. /***** Errors  Errors  Errors  Errors  Errors  Errors     *******/
  110. Err1:
  111.   Say "*** Hey Dude, you put in garbage for the disk letter ***"
  112.   Pause
  113.   Exit 100   /* Exit with a return code of 100  */
  114.  
  115. Err2:
  116.   Say "*** Error deleting old $WORK$.TPF file ***"
  117.   Pause
  118.   Exit rc   /* Return the error code received  */
  119.  
  120. Err3:
  121.   Say "*** Error creating new $WORK$.TPF file ***"
  122.   Pause
  123.   Exit rc   /* Return the error code received  */
  124.  
  125.