home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netdor3.zip / DISK_12 / IMAGE11.ZIP / ADMTOOLS / REPALL.CMD < prev    next >
OS/2 REXX Batch file  |  1993-09-27  |  7KB  |  190 lines

  1. /*****************************************************************************
  2.  *         REPALL - Replace, Create, Delete File on all CORE servers         *
  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.  * Version 1.0 - 30 Oct 92                                                   *
  13.  * 14 Jun 93 - teb                                                           *
  14.  * - Remove /D from NETCLOSE call.                                           *
  15.  * - Use COUENV instead of COREENV.                                          *
  16.  *****************************************************************************/
  17. parse upper arg File '/' Opts
  18. if File = '' | abbrev(strip(File), '?')
  19.   then signal Tell
  20.            
  21. call LoadRxUtils
  22. call rxfuncadd 'RXCOUINFO', 'COUENV', 'RXCOUINFO'
  23.  
  24. if Opts <> '' 
  25.   then Opts = '/'Opts
  26. Force = wordpos('/FORCE', Opts)
  27. if Force > 0
  28.   then do
  29.     Opts = delword(Opts, Force, 1)
  30.     Force = 1
  31.   end
  32.  
  33. /**** PTR 10216 start ****/
  34. if (Opts <> '' & (words(Opts) > 1 | wordpos(Opts, '/U /A /D') = 0))
  35.   then do
  36.     say
  37.     say 'Error: Incorrect syntax.  Use REPALL ? for help.'
  38.     exit 2
  39.   end
  40. /**** PTR 10216 end ****/
  41.  
  42. /**** PTR 97 start ****/
  43. if verify(File, '*?', 'M') > 0
  44.   then if Opts = '/D'
  45.     then do
  46.       say 'Error: Delete not supported for wildcards.' 
  47.       exit 2
  48.     end
  49.     else nop
  50.   else if \rxFileExist(File)
  51.     then if Opts = '/D'
  52.       then say 'Warning: "'File'" not found.'
  53.       else do
  54.         say 'Error: "'File'" not found.'
  55.         exit 2
  56.       end
  57. /**** PTR 97 end ****/
  58.  
  59. Where = directory()
  60. if pos('\', File) = 0
  61.   then if right(Where, 1) = '\'
  62.     then File = Where||File
  63.     else File = Where'\'File
  64.   else if substr(File, 2, 1) <> ':'
  65.     then do; say 'Full path is required.'; exit 2; end
  66.  
  67. Target = substr(filespec('PATH', File), 2)
  68. if Target <> ''
  69.   then Target = '\'left(Target, length(Target)-1)
  70.  
  71. if abbrev(translate(Target), '\LOCAL') & \Force
  72.   then do
  73.     say 
  74.     say ' Warning:  LOCAL directory specified.  If you continue, the file(s)'
  75.     say ' be replaced on *all* servers, regardless of directory scope.'
  76.     say 
  77.     say ' Do you want to continue (Y/N)?'
  78.     do forever
  79.       pull Resp .
  80.       if Resp = ''
  81.         then iterate
  82.       if abbrev(Resp, 'Y')
  83.         then leave
  84.         else exit 2
  85.     end
  86.   end
  87.  
  88. /**** PTR 97 start ****/
  89. CDr = strip(rxCouInfo('GET', 'REMOTE'), 'T', '\')
  90. NetClose = CDr'\ADMTOOLS\NETCLOSE.EXE'
  91. /**** PTR 97 end ****/
  92.  
  93. say
  94. say ' Replacing' File 'to all servers...'
  95. CDr = strip(rxCouInfo('GET', 'REMOTE'), 'T', '\')'\'
  96. Sep = '1A'x
  97. List = 'NAMEFIND'(CDr'LOCAL\COMPLEX\SERVERS.COR :TYPE SERVER :NICK :ID :SPECID /RETURN *')
  98. if abbrev(List, 'ERROR:')
  99.   then do
  100.     say 'Server names could not be determined.'
  101.     exit 2
  102.   end
  103. do while List <> ''
  104.   parse var List Entry ':NICK.' List
  105.   if Entry = ''
  106.     then iterate
  107.   parse var Entry Server (Sep) Ids
  108.   do while Ids <> ''
  109.     parse var Ids '.' Id (Sep) Ids
  110.     call DoIt '\\'Server'\'Id
  111.   end
  112. end
  113. if Opts = '/D'
  114.   then '@DEL' File
  115. exit 0
  116.  
  117. DoIt:
  118. /**
  119.  ** Path  = target UNC root (eg, \\CORELABS\CORFLOOR)
  120.  ** TFile = target UNC filename (eg, \\CORELABS\COREFLOOR\DIR\A.CMD)
  121.  ** TPath = target UNC path (eg, \\CORELABS\CORFLOOR\DIR)
  122.  **/
  123. parse arg Path
  124. say
  125. say ' *** Replacing to' Path'...'
  126. TFile = Path||substr(File, 3)
  127. TPath = Path||Target
  128. /**** PTR 97 start ****/
  129. if Opts <> '/A'
  130.   then '@'NetClose TFile '/Q'
  131. if Opts = '/D'
  132.   then if rxFileExist(TFile)
  133.     then if rxDelete(TFile) = 0
  134.       then say TFile 'deleted.'
  135.       else say TFile 'could not be deleted.'
  136.     else say TFile 'does not exist.'
  137. /**** PTR 97 end ****/
  138.   else '@REPLACE' File TPath Opts
  139. '@NET USE' Path '/D >NUL'
  140. return 0
  141.  
  142. LoadRxUtils: procedure                                                   
  143. if \rxfuncadd('RXLOADFUNCS', 'RXUTILS', 'RXLOADFUNCS')                   
  144.   then do                                                                
  145.     signal on syntax name LoadRxUtils2                                   
  146.     call rxLoadFuncs 'QUIET'                                             
  147.   end                                                                    
  148. return 0                                                                 
  149.                                                                          
  150. LoadRxUtils2:                                                            
  151. signal off syntax    /* Turn off temp error trap */                      
  152. /* If you have an error trap in the program, use the following line inste
  153. signal on syntax name syntax                                             
  154. */                                                                       
  155. select                                                                   
  156.   when rc = 40                                                           
  157.     then call rxLoadFuncs                                                
  158.   when rc = 43                                                           
  159.     then do                                                              
  160.       say 'Error:  RXUTILS.DLL not found.'                               
  161.       exit 2                                                             
  162.     end                                                                  
  163.   otherwise do                                                           
  164.     say 'Error: Error' rc 'registering RXUTILS functions.'               
  165.     exit 2                                                               
  166.   end                                                                    
  167. end                                                                      
  168. return 0                                                                 
  169.  
  170. Tell:
  171. say
  172. say ' REPALL will replace, create, or delete a file on all ID and SPECID'
  173. say ' aliases specified in the SERVERS.COR file.'
  174. say
  175. say ' REPALL source [option]'
  176. say 
  177. say ' source: The name of the file on the CORE image to be used.  May contain'
  178. say '         wildcards (except if /D is specified).  If the file is in the'
  179. say '         current directory, the path need not be specified.'
  180. say 
  181. say ' "option" can be one of the following:'
  182. say '   /U   - Update the file if the source is newer.'
  183. say '   /A   - Add (Create) the file on all the aliases.'
  184. say '   /D   - Delete the file from all the aliases.'
  185. say
  186. say ' If no option is specified, the file is replaced if it exists.'
  187. say ' Note:  due to LS bug, /U may not work.  Run REPALL w/ no option instead.'
  188. say
  189. exit 0
  190.