home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netdor2.zip / DISK_10 / IMAGE9.ZIP / MB.CMD < prev    next >
OS/2 REXX Batch file  |  1993-09-24  |  7KB  |  234 lines

  1. /*****************************************************************************
  2.  *                            MB - Mirror Backup                             *
  3.  *                       T. Bridgman (CORE at WATSON)                        *
  4.  *****************************************************************************
  5.  *                    Licensed Materials-Property of IBM                     *
  6.  *               5604-472 (c) Copyright IBM Corporation, 1993                *
  7.  *                           All rights reserved.                            *
  8.  *                  US Government Users Restricted Rights -                  *
  9.  *                 Use, duplication or disclosure restricted                 *
  10.  *                by GSA ADP Schedule Contract with IBM Corp.                *
  11.  *****************************************************************************
  12.  * 31 Jan 92 - teb                                                           *
  13.  * - Add check for TEE if RXUTILS is present.                                *
  14.  *****************************************************************************/
  15. trace 'O'
  16. '@ECHO OFF'
  17. signal on syntax
  18. signal on halt
  19. signal on failure
  20. signal on novalue
  21.  
  22. parse arg Args
  23. if abbrev(strip(Args), '?')
  24.   then do
  25.     say 'MB does not have on-line help.'
  26.     say 'Please refer to the NetDoor Administrator''s Guide.'
  27.     exit 99
  28.   end
  29.  
  30. /* Get time and date that backup starts */
  31. StartTS = date() time()
  32. /* Start the backup */
  33. say 'Backup begins' StartTS
  34. parse value '' with SDr TDr Profile StatArg
  35. parse value '0' with 1 NetSDr 1 NetTDr
  36.  
  37. do I = 1 to min(words(Args), 4)
  38.   call ReadArgs word(Args, I)
  39. end
  40.  
  41. if 'REGFUNC'('COUENV') <> 0
  42.   then do
  43.     say 'Could not register COUENV functions.'
  44.     exit 2
  45.   end
  46.  
  47. MBDir = strip(rxCouInfo('GET','REMOTE'),'T','\')'\MB'
  48. UDr = rxCouInfo('GET','LOCAL')
  49. call setlocal
  50. call 'MODPATH' 'PATH ADD' MBDir
  51. call 'MODPATH' 'DPATH ADD' UDr';'MBDir
  52.  
  53. call ReadProfile
  54. if SDr='' | TDr = ''
  55.   then call ErrExit 'Could not determine source or target drive.'
  56.  
  57. /*the following line has MB abort if the profile file is not found */
  58. if \FileExist(QProfile)
  59.   then call ErrExit 'The profile' Profile 'can not be found.'
  60.  
  61. if \rxfuncquery('RXSEARCHPATH')
  62.   then select
  63.     when rxSearchPath('PATH', 'TEE.EXE') <> ''
  64.       then Tee = 'TEE.EXE'
  65.     when rxSearchPath('PATH', 'TEE.COM') <> ''
  66.       then Tee = 'TEE.COM'
  67.     otherwise
  68.       Tee = ''
  69.   end
  70.   else Tee = 'TEE'
  71. if Tee <> ''
  72.   then Log = '|' Tee TDr'\$$$MB$$$.LOG'
  73.   else Log = ''
  74.  
  75. if 'REGFUNC'('COUENV') <> 0
  76.   then do
  77.     say 'Could not register COUENV functions.'
  78.     exit 2
  79.   end
  80.  
  81. BackupExec = 'MBMIRROR' SDr TDr Profile '| MBSTAT' SDr TDr Profile StatArg,
  82.     Log
  83. if StatArg = '/V'
  84.   then say BackupExec
  85. BackupExec
  86. call CleanExit 0
  87.  
  88. CleanExit:
  89. signal off novalue
  90. parse arg OutC
  91. if NetSDr = 1
  92.   then 'GIME.EXE' SDr '/D'
  93. if NetTDr = 1
  94.   then 'GIME.EXE' TDr '/D'
  95. call stream  QProfile, 'C', 'CLOSE'
  96. say 'Backup started:' StartTS
  97. say 'Backup ends:   ' date() time()
  98. say copies('=', 70)
  99. exit OutC
  100.  
  101. ErrExit:
  102. parse arg EMsg
  103. say 'Message from Mirror Backup:'
  104. say EMsg
  105. call CleanExit 2
  106.  
  107. ReadArgs:
  108. parse arg Input
  109. parse value '0' with 1 NetName 1 Already
  110.  
  111. if pos(left(Input, 1), '-/@') = 0 & right(Input, 1) <> ':'
  112.   then do
  113.     'GIME.EXE' Input '| RXQUEUE'
  114.      do queued()
  115.        parse pull ALine
  116.        say ALine
  117.        ALine = translate(ALine)
  118.        if abbrev(ALine, 'THE NETNAME') | ALine = ''
  119.          then leave
  120.      end
  121.      parse value Aline with . ' IS ' Already . 'ASSIGNED TO DRIVE ' Drive .
  122.      if Drive = ''
  123.        then call ErrExit 'Can not attach to' Input
  124.      Input = Drive
  125.      do queued()
  126.        pull ALine
  127.        say ALine
  128.      end
  129.      NetName = 1
  130.      Already = (Already = 'ALREADY')
  131.   end
  132.  
  133. select
  134.   when abbrev(Input, '@')
  135.     then Profile = Input
  136.   when abbrev(Input, '/') | abbrev(Input, '-')
  137.     then if wordpos(substr(Input, 2), 'Q V') <> 0 & StatArg = ''
  138.       then StatArg = '/'substr(Input, 2)
  139.   when right(Input, 1) = ':'
  140.     then if SDr = ''
  141.       then do
  142.         SDr = right(Input, 2)
  143.         NetSDr = (NetName & \Already)
  144.      end
  145.      else if TDr = ''
  146.        then do
  147.          TDr = right(Input,2)
  148.          NetTDr = (NetName & \Already)
  149.        end
  150.    otherwise nop
  151. end
  152. return
  153.  
  154. ReadProfile:
  155. if Profile = ''
  156.   then Profile = '@MB.PRO'
  157. ProfName = substr(strip(Profile), 2)
  158. QProfile = ProfName
  159. DPath = value('DPATH',,'OS2ENVIRONMENT')
  160. do while DPath <> '' & lines(QProfile) = 0
  161.   parse var DPath Path ';' DPath
  162.   QProfile = strip(Path)'\'ProfName
  163. end
  164. if lines(QProfile)
  165.   then call ReadProfile2
  166. return
  167.  
  168. ReadProfile2:
  169. do 100 until Ok
  170.   Ok = (abbrev(stream(QProfile, 'C', 'OPEN READ'), 'READY'))
  171. end
  172. if \Ok
  173.   then call ErrExit 'Could not open profile' QProfile'.'
  174. ProtectList = ''
  175. SkipList    = ''
  176. do while lines(QProfile) > 0
  177.   parse upper value linein(QProfile) with ProVerb ProArg
  178.   ProArg = strip(ProArg)
  179.   select
  180.     when ProVerb = 'SOURCEDRIVE' & SDr = ''
  181.       then SDr = ProArg
  182.     when ProVerb = 'TARGETDRIVE' & Tdr = ''
  183.       then TDr = ProArg
  184.     when (ProVerb = 'QUIET' | ProVerb = 'VERBOSE') & StatArg = ''
  185.       then StatArg = '/'left(ProVerb, 1)
  186.     when ProVerb = 'SKIPFILE'
  187.       then SkipList = SkipList ProArg
  188.     when ProVerb = 'PROTECTFILE'
  189.       then ProtectList = ProtectList ProArg
  190.     otherwise nop
  191.   end
  192. end
  193.  
  194. call stream QProfile, 'C', 'CLOSE'
  195. call CheckList 'skipfile', SkipList, '"EA DATA. SF"', 'SWAPPER.DAT',,
  196.     '$$$MB$$$.LOG', '"WP ROOT. SF"'
  197. call CheckList 'protectfile', ProtectList, '"EA DATA. SF"', '$$$MB$$$.LOG',,
  198.     '"WP ROOT. SF"'
  199. call stream QProfile, 'C', 'CLOSE'
  200. return
  201.  
  202. CheckList:
  203. parse arg Attr, List
  204. do I = 3 to arg()
  205.   File = arg(I)
  206.   if wordpos(File, List) = 0
  207.     then call lineout QProfile, left(Attr, 12) File
  208. end
  209. return
  210.  
  211. /*****************************************************************************
  212.  * FILEEXIST QFileName                                                       *
  213.  *  Return 1 if the specified fully-qualified file exists, or 0 if not.      *
  214.  *****************************************************************************/
  215. FileExist: procedure
  216. parse arg TestFile .
  217. return \(stream(TestFile, 'C','QUERY SIZE') = '')
  218.  
  219. novalue:
  220. say 'Novalue error ('condition('D')') raised in line' sigl'.'
  221. call CleanExit 2
  222.  
  223. syntax:
  224. say 'Syntax error' rc '('errortext(rc)') raised in line' sigl'.'
  225. call CleanExit 2
  226.  
  227. halt:
  228. say 'Process terminated from external environment.'
  229. call CleanExit 2
  230.  
  231. failure:
  232. say 'Failure condition' rc 'raised in line' sigl'.'
  233. call CleanExit 2
  234.