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 >
Wrap
OS/2 REXX Batch file
|
1993-09-24
|
7KB
|
234 lines
/*****************************************************************************
* MB - Mirror Backup *
* 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. *
*****************************************************************************
* 31 Jan 92 - teb *
* - Add check for TEE if RXUTILS is present. *
*****************************************************************************/
trace 'O'
'@ECHO OFF'
signal on syntax
signal on halt
signal on failure
signal on novalue
parse arg Args
if abbrev(strip(Args), '?')
then do
say 'MB does not have on-line help.'
say 'Please refer to the NetDoor Administrator''s Guide.'
exit 99
end
/* Get time and date that backup starts */
StartTS = date() time()
/* Start the backup */
say 'Backup begins' StartTS
parse value '' with SDr TDr Profile StatArg
parse value '0' with 1 NetSDr 1 NetTDr
do I = 1 to min(words(Args), 4)
call ReadArgs word(Args, I)
end
if 'REGFUNC'('COUENV') <> 0
then do
say 'Could not register COUENV functions.'
exit 2
end
MBDir = strip(rxCouInfo('GET','REMOTE'),'T','\')'\MB'
UDr = rxCouInfo('GET','LOCAL')
call setlocal
call 'MODPATH' 'PATH ADD' MBDir
call 'MODPATH' 'DPATH ADD' UDr';'MBDir
call ReadProfile
if SDr='' | TDr = ''
then call ErrExit 'Could not determine source or target drive.'
/*the following line has MB abort if the profile file is not found */
if \FileExist(QProfile)
then call ErrExit 'The profile' Profile 'can not be found.'
if \rxfuncquery('RXSEARCHPATH')
then select
when rxSearchPath('PATH', 'TEE.EXE') <> ''
then Tee = 'TEE.EXE'
when rxSearchPath('PATH', 'TEE.COM') <> ''
then Tee = 'TEE.COM'
otherwise
Tee = ''
end
else Tee = 'TEE'
if Tee <> ''
then Log = '|' Tee TDr'\$$$MB$$$.LOG'
else Log = ''
if 'REGFUNC'('COUENV') <> 0
then do
say 'Could not register COUENV functions.'
exit 2
end
BackupExec = 'MBMIRROR' SDr TDr Profile '| MBSTAT' SDr TDr Profile StatArg,
Log
if StatArg = '/V'
then say BackupExec
BackupExec
call CleanExit 0
CleanExit:
signal off novalue
parse arg OutC
if NetSDr = 1
then 'GIME.EXE' SDr '/D'
if NetTDr = 1
then 'GIME.EXE' TDr '/D'
call stream QProfile, 'C', 'CLOSE'
say 'Backup started:' StartTS
say 'Backup ends: ' date() time()
say copies('=', 70)
exit OutC
ErrExit:
parse arg EMsg
say 'Message from Mirror Backup:'
say EMsg
call CleanExit 2
ReadArgs:
parse arg Input
parse value '0' with 1 NetName 1 Already
if pos(left(Input, 1), '-/@') = 0 & right(Input, 1) <> ':'
then do
'GIME.EXE' Input '| RXQUEUE'
do queued()
parse pull ALine
say ALine
ALine = translate(ALine)
if abbrev(ALine, 'THE NETNAME') | ALine = ''
then leave
end
parse value Aline with . ' IS ' Already . 'ASSIGNED TO DRIVE ' Drive .
if Drive = ''
then call ErrExit 'Can not attach to' Input
Input = Drive
do queued()
pull ALine
say ALine
end
NetName = 1
Already = (Already = 'ALREADY')
end
select
when abbrev(Input, '@')
then Profile = Input
when abbrev(Input, '/') | abbrev(Input, '-')
then if wordpos(substr(Input, 2), 'Q V') <> 0 & StatArg = ''
then StatArg = '/'substr(Input, 2)
when right(Input, 1) = ':'
then if SDr = ''
then do
SDr = right(Input, 2)
NetSDr = (NetName & \Already)
end
else if TDr = ''
then do
TDr = right(Input,2)
NetTDr = (NetName & \Already)
end
otherwise nop
end
return
ReadProfile:
if Profile = ''
then Profile = '@MB.PRO'
ProfName = substr(strip(Profile), 2)
QProfile = ProfName
DPath = value('DPATH',,'OS2ENVIRONMENT')
do while DPath <> '' & lines(QProfile) = 0
parse var DPath Path ';' DPath
QProfile = strip(Path)'\'ProfName
end
if lines(QProfile)
then call ReadProfile2
return
ReadProfile2:
do 100 until Ok
Ok = (abbrev(stream(QProfile, 'C', 'OPEN READ'), 'READY'))
end
if \Ok
then call ErrExit 'Could not open profile' QProfile'.'
ProtectList = ''
SkipList = ''
do while lines(QProfile) > 0
parse upper value linein(QProfile) with ProVerb ProArg
ProArg = strip(ProArg)
select
when ProVerb = 'SOURCEDRIVE' & SDr = ''
then SDr = ProArg
when ProVerb = 'TARGETDRIVE' & Tdr = ''
then TDr = ProArg
when (ProVerb = 'QUIET' | ProVerb = 'VERBOSE') & StatArg = ''
then StatArg = '/'left(ProVerb, 1)
when ProVerb = 'SKIPFILE'
then SkipList = SkipList ProArg
when ProVerb = 'PROTECTFILE'
then ProtectList = ProtectList ProArg
otherwise nop
end
end
call stream QProfile, 'C', 'CLOSE'
call CheckList 'skipfile', SkipList, '"EA DATA. SF"', 'SWAPPER.DAT',,
'$$$MB$$$.LOG', '"WP ROOT. SF"'
call CheckList 'protectfile', ProtectList, '"EA DATA. SF"', '$$$MB$$$.LOG',,
'"WP ROOT. SF"'
call stream QProfile, 'C', 'CLOSE'
return
CheckList:
parse arg Attr, List
do I = 3 to arg()
File = arg(I)
if wordpos(File, List) = 0
then call lineout QProfile, left(Attr, 12) File
end
return
/*****************************************************************************
* FILEEXIST QFileName *
* Return 1 if the specified fully-qualified file exists, or 0 if not. *
*****************************************************************************/
FileExist: procedure
parse arg TestFile .
return \(stream(TestFile, 'C','QUERY SIZE') = '')
novalue:
say 'Novalue error ('condition('D')') raised in line' sigl'.'
call CleanExit 2
syntax:
say 'Syntax error' rc '('errortext(rc)') raised in line' sigl'.'
call CleanExit 2
halt:
say 'Process terminated from external environment.'
call CleanExit 2
failure:
say 'Failure condition' rc 'raised in line' sigl'.'
call CleanExit 2