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 >
Wrap
OS/2 REXX Batch file
|
1993-09-27
|
7KB
|
190 lines
/*****************************************************************************
* REPALL - Replace, Create, Delete File on all CORE servers *
* T. Bridgman - (CORE at WATSON) *
*****************************************************************************
* 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. *
*****************************************************************************
* Version 1.0 - 30 Oct 92 *
* 14 Jun 93 - teb *
* - Remove /D from NETCLOSE call. *
* - Use COUENV instead of COREENV. *
*****************************************************************************/
parse upper arg File '/' Opts
if File = '' | abbrev(strip(File), '?')
then signal Tell
call LoadRxUtils
call rxfuncadd 'RXCOUINFO', 'COUENV', 'RXCOUINFO'
if Opts <> ''
then Opts = '/'Opts
Force = wordpos('/FORCE', Opts)
if Force > 0
then do
Opts = delword(Opts, Force, 1)
Force = 1
end
/**** PTR 10216 start ****/
if (Opts <> '' & (words(Opts) > 1 | wordpos(Opts, '/U /A /D') = 0))
then do
say
say 'Error: Incorrect syntax. Use REPALL ? for help.'
exit 2
end
/**** PTR 10216 end ****/
/**** PTR 97 start ****/
if verify(File, '*?', 'M') > 0
then if Opts = '/D'
then do
say 'Error: Delete not supported for wildcards.'
exit 2
end
else nop
else if \rxFileExist(File)
then if Opts = '/D'
then say 'Warning: "'File'" not found.'
else do
say 'Error: "'File'" not found.'
exit 2
end
/**** PTR 97 end ****/
Where = directory()
if pos('\', File) = 0
then if right(Where, 1) = '\'
then File = Where||File
else File = Where'\'File
else if substr(File, 2, 1) <> ':'
then do; say 'Full path is required.'; exit 2; end
Target = substr(filespec('PATH', File), 2)
if Target <> ''
then Target = '\'left(Target, length(Target)-1)
if abbrev(translate(Target), '\LOCAL') & \Force
then do
say
say ' Warning: LOCAL directory specified. If you continue, the file(s)'
say ' be replaced on *all* servers, regardless of directory scope.'
say
say ' Do you want to continue (Y/N)?'
do forever
pull Resp .
if Resp = ''
then iterate
if abbrev(Resp, 'Y')
then leave
else exit 2
end
end
/**** PTR 97 start ****/
CDr = strip(rxCouInfo('GET', 'REMOTE'), 'T', '\')
NetClose = CDr'\ADMTOOLS\NETCLOSE.EXE'
/**** PTR 97 end ****/
say
say ' Replacing' File 'to all servers...'
CDr = strip(rxCouInfo('GET', 'REMOTE'), 'T', '\')'\'
Sep = '1A'x
List = 'NAMEFIND'(CDr'LOCAL\COMPLEX\SERVERS.COR :TYPE SERVER :NICK :ID :SPECID /RETURN *')
if abbrev(List, 'ERROR:')
then do
say 'Server names could not be determined.'
exit 2
end
do while List <> ''
parse var List Entry ':NICK.' List
if Entry = ''
then iterate
parse var Entry Server (Sep) Ids
do while Ids <> ''
parse var Ids '.' Id (Sep) Ids
call DoIt '\\'Server'\'Id
end
end
if Opts = '/D'
then '@DEL' File
exit 0
DoIt:
/**
** Path = target UNC root (eg, \\CORELABS\CORFLOOR)
** TFile = target UNC filename (eg, \\CORELABS\COREFLOOR\DIR\A.CMD)
** TPath = target UNC path (eg, \\CORELABS\CORFLOOR\DIR)
**/
parse arg Path
say
say ' *** Replacing to' Path'...'
TFile = Path||substr(File, 3)
TPath = Path||Target
/**** PTR 97 start ****/
if Opts <> '/A'
then '@'NetClose TFile '/Q'
if Opts = '/D'
then if rxFileExist(TFile)
then if rxDelete(TFile) = 0
then say TFile 'deleted.'
else say TFile 'could not be deleted.'
else say TFile 'does not exist.'
/**** PTR 97 end ****/
else '@REPLACE' File TPath Opts
'@NET USE' Path '/D >NUL'
return 0
LoadRxUtils: procedure
if \rxfuncadd('RXLOADFUNCS', 'RXUTILS', 'RXLOADFUNCS')
then do
signal on syntax name LoadRxUtils2
call rxLoadFuncs 'QUIET'
end
return 0
LoadRxUtils2:
signal off syntax /* Turn off temp error trap */
/* If you have an error trap in the program, use the following line inste
signal on syntax name syntax
*/
select
when rc = 40
then call rxLoadFuncs
when rc = 43
then do
say 'Error: RXUTILS.DLL not found.'
exit 2
end
otherwise do
say 'Error: Error' rc 'registering RXUTILS functions.'
exit 2
end
end
return 0
Tell:
say
say ' REPALL will replace, create, or delete a file on all ID and SPECID'
say ' aliases specified in the SERVERS.COR file.'
say
say ' REPALL source [option]'
say
say ' source: The name of the file on the CORE image to be used. May contain'
say ' wildcards (except if /D is specified). If the file is in the'
say ' current directory, the path need not be specified.'
say
say ' "option" can be one of the following:'
say ' /U - Update the file if the source is newer.'
say ' /A - Add (Create) the file on all the aliases.'
say ' /D - Delete the file from all the aliases.'
say
say ' If no option is specified, the file is replaced if it exists.'
say ' Note: due to LS bug, /U may not work. Run REPALL w/ no option instead.'
say
exit 0