home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rdebug21.zip
/
CHORES2.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-03-25
|
6KB
|
246 lines
/*H* CHORES2.REX 01-06-93 23:55*/
Parse Arg prog parms
prog=translate(prog)
me=prog
Parse source sys .
sys.=0
if sys='OS/2' then sys.os2=1
else if sys='PCDOS' then sys.dos=1
If arg(1)=? Then Exit tell(me)
i=lastpos('\',prog)
If i>0 Then prog=substr(prog,i+1)
again?=0
Call find_program parms
Exit
find_program:
Signal On syntax /*trap unknown program*/
Signal Value prog
SYNTAX:
If again? Then Say 'Coding error in program' prog
Else Say "program" prog "not found in CHORES2"
again?=1
Exit; BKUPZZ: /* nop'd because it hangs */
Trace o?r
dir=doscd()
Call doschdir('c:\')
Say 'Doing copy of backup To D Drive, please wait.'
'c:\nu\ds d'
s=dosdir('c:\zz*.bat','n')
Do N=1 While s <> ''
fn.n=s
s=dosdir(,'n')
End
n=n-1
If n>3 Then Do n=1 To n-3
fn.n
'if exist' fn.n 'del' fn.n
End
Call doschdir(dir)
'c:\nu\ds n'
Return; CHECKCOM:
worry='is wrong. Time To worry.'
/*files='c:\dos\COMMAND.COM 47845 04/09/91 c:\IO.SYS 33430 04/09/91 c:\MSDOS.SYS 37394 04/09/91'*/
files='a:\COMMAND.COM 47845 04/09/91 a:\IO.SYS 33430 04/09/91 a:\MSDOS.SYS 37394 04/09/91'
Do N=1 TO 9 By 3
file=word(files,n)
size=word(files,n+1)
date=word(files,n+2)
a=dosdir(file,,'hsd')
Parse Var a . fsize fdate .
If size<>fsize Then Say file 'size' worry
If date<>fdate Then Say file 'date' worry
End
return; CHKDSK:
if sys.dos then do
f='e:\aa.aa'
g='e:\aa.chk'
h='e:\aa.err'
end
else do
f='c:\aa.aa'
g='c:\aa.chk'
h='c:\aa.err'
end
'CHKDSK c: >' f
'find "non-contiguous" <' f '>' g
'find "lost clusters" <' f '>>' g
'find "cross-linked" <' f '>>' g
'copy' g h '>nul'
'if exist' h 'x.rex' f
/*if state(h) =0 then 'x.rex' f*/
'if exist' f 'del' f
'if exist' g 'del' g
Return; clean:
Say 'Doing a cleanup of files in certain directories, please wait'
call delete '\*.BAK \RAM\*.BAK \RAM2\*.BAK \MYA\*.BAK \MYC\*.BAK \TC\*.BAK \LET\*.BAK'
/* return too slow */
/*queue 'd:\bin\SWEEP If exist aa*.* del aa*.*'*/
queue 'c:\bin\SWEEP del aa*.*'
Return; DELETE: procedure
arg list
do n=1 to words(list)
file=word(list,n)
if pos('*',file,)>0 | pos('?',file)>0 then do
if dosdir(file)<>'' then 'del' file
end
else call dosdel file
end
Return; CLEANUP:
Parse Value date('u') With mo '/' day '/' yr
If ((day%7)//2)<>0 Then Call process_directories
Exit
PROCESS_DIRECTORIES:
savecd = doscd()
directory = savecd
If right(directory,1) = '\' Then
directory = left(directory, length(directory) - 1)
Call tree directory, Command
Call doschdir savecd
Return
TREE: Procedure
Parse Arg directory, Command
Call doschdir directory
Call erase
name = dosdir(directory'\*.*','n','d','d')
position = dosdirpos()
Do While name <> ''
If name <> '.' & name <> '..' Then
Call tree directory'\'name, Command
name = dosdir(,'n','d','d',position)
position = dosdirpos()
End
Return
PROCESS_ALL_DIRECTORIES:
/*traverse tree of directories, starting at*/
/*current directory, invoking ds */
/*in each directory. */
'cd \'
savecd=doscd()
directory=savecd
If right(directory,1) = '\' Then
directory=left(directory,length(directory) - 1)
Call tree directory
Call doschdir savecd
Return
TREE: Procedure
Parse Arg directory
Call doschdir directory
Call erase
name=dosdir(directory'\*.*','n','d','d')
position=dosdirpos()
Do While name <> ''
If name <> '.' & name <> '..' Then
Call tree directory'\'name
name=dosdir(,'n','d','d',position)
position=dosdirpos()
End
Return; PROCESS_PATH_DIRECTORIES:
path=dosenv('PATH')';'
savedir=doscd()
savedriv=dosdrive()
Do Until path=''
Parse Var path dir ';' path
If length(dir)<4 Then Iterate
Call doschdir dir
Call erase
End
Call dosdrive savedriv
Call doschdir savedir
Return; COMPRESS:
Say 'Will REBOOT System'
Say 'Remember to REM out all devices in config.sys'
Say 'And invoke SD c:'
Say 'Hit any key to continue...'
pull .
queue 'WARM'
exit; ERASE:
'if exist aa*.* del aa*.*'
'if exist *.bak del *.bak'
'if exist *.aus del *.aus'
/*'d:\nu\ds.exe N >nul'*/
'c:\nu\ds.exe N >nul'
Return; DEL:
Arg p1
'dir' p1 '/w'
Say "If you want To erase" p1 "enter Y..."
ans=upper(inkey())
If ans='Y' Then Do
'copy' p1 'c:\bkup'
'del' p1; End
Exit; QUIET:
''arg(1)
Return rc
action=trace('o')
If pc? Then Address dos 'CTTY NUL'
Else Address Command 'SET CMSTYPE HT'
''arg(1)
src = rc
If pc? Then Address dos 'CTTY CON'
Else Address Command 'SET CMSTYPE RT'
trace value action
Return src; TON:
Arg token
If token=? Then Exit tell(me,'<?>','summarize the logon and off',
'time entries from start and bye execs.')
file='c:\log\time.log'
fileout='c:\log\temp.log'
read?=1
Call lineout file
Call lineout fileout
'c:\rexx\listfile' fileout '(notype'
If rc=0 Then 'erase' fileout
Do While lines(file)
If read? Then t=linein(file)
Parse Var t date1 time1 sw1 date2 time2 sw2
read?=1
If sw2='' Then Do n=1 Until sw2='logoff'
If lines(file)=0 Then Leave
e=linein(file)
Parse Var e date2 time2 sw2
If sw2='logoff' Then Call calc_elapse
If date1<>date2 Then Do
Call lineout fileout, t
t=e
read?=0
Leave
End
End
If read? Then Call lineout fileout, t
sw2=
End
If sw2<>'' Then Call lineout fileout, t
Call lineout file
Call lineout fileout
'if exist' file 'erase' file
i=lastpos('\',file)
'rename' fileout substr(file,i+1)
Return; CALC_ELAPSE:
mins1=(left(time1,2))*60+substr(time1,4,2)
mins2=(left(time2,2))*60+substr(time2,4,2)
If mins1>mins2 Then mins2=mins2+1440
hrs=(mins2-mins1)%60
mins=(mins2-mins1)//60
elapsed=right(hrs,2)':'right(mins,2,'0')
t=t e n elapsed
Return; STATE:
Arg specs
If pc? Then Do
If dosdir(specs)='' Then rc=28
Else rc=0; End
Else 'STATE' specs
Return rc