home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
job201.zip
/
JOBBER2.CMD
next >
Wrap
OS/2 REXX Batch file
|
1994-07-22
|
3KB
|
118 lines
/* JOBBER2.CMD v2.01 (c)Anglopean Limited 1994*/
/* State command file purpose */
say 'JOBBER2.CMD v2.01 (c) Anglopean Limited 1994'
say
say 'Automatic job scheduler for OS/2'
say
/* Define Global variables */
'@ECHO OFF'
LogFile = 'C:\JOBBER\JOBBER2.LOG'
today = Date(B)//7
say 'Today is 'Today
/* Read in config file */
ConfigFile = 'JOBBER2.DAT'
CfgCntr = 0
rc = STREAM(ConfigFile, 'C', 'OPEN')
if rc <> 'READY:' then do
say 'File JOBBER2.DAT does not exist, no jobs defined, program halted.'
exit
end /* Do */
Do While lines(ConfigFile)
rc = LineIn(ConfigFile)
rc = Strip(rc, 'b', ' ')
If Left(rc, 1) <> ';' & Length(rc) <> 0 then do
Parse Value rc with CmdFile ',' Time ',' Flag ',' ExecuteDays
If ExecuteDays = '' then
ExecuteDays = '0123456'
CfgCntr = CfgCntr +1
action.CfgCntr = CmdFile
Parse Value Time with ath.cfgcntr ':' atm.cfgcntr
disk.cfgcntr = Flag
days.cfgcntr = ExecuteDays
done.cfgcntr = 0
End /* If */
End /* Do */
rc = stream(ConfigFile, 'C', 'CLOSE')
/* Display Config File Contents */
say 'JOBBER2.DAT config file dump'
say
Do Cntr = 1 to CfgCntr
say action.cntr 'at' ath.cntr':'atm.cntr 'or when' disk.cntr 'exists (on days 'days.cntr')'
end
/* Tidy up the screen */
say
say 'Starting main JOBBER process'
say
StopFlag = 0
/* Define TEMPTIME */
Parse Value Time() with h':'m':'s
TempTime = m
/* Main Procdedure */
Do While StopFlag = 0
/* Pause until the minute changes */
Do While m = TempTime
Parse Value Time() with h':'m':'s
End
TempTime = m
If h = 0 & m = 0 then do
do cntr = 1 to cfgcntr
done.cntr = 0
end /* Do */
today = Date(B)//7
end /* If */
say Date() Left(Time(), 5) 'checking for jobs to execute'
If Exist('C:\JOBBER\STOP.FLG') = 1 then StopFlag = 1
Do cntr = 1 to CfgCntr
If pos(today, days.cntr) <> 0 & ath.cntr = h & atm.cntr = m & done.cntr = 0 then do
rc = LineOut(LogFile, Date() Left(Time(), 5) 'starting task' action.cntr 'due to time criteria')
rc = stream(LogFile, 'C', 'CLOSE')
say Date() Left(Time(), 5) 'starting task' action.cntr 'due to time criteria'
start action.cntr
done.cntr = 1
End /* If */
End /* Do */
Do cntr = 1 to CfgCntr
If exist(disk.cntr) then do
rc = LineOut(LogFile, Date() Left(Time(), 5) 'starting task' action.cntr 'due to flag file')
rc = stream(LogFile, 'C', 'CLOSE')
say Date() Left(Time(), 5) 'starting task' action.cntr 'due to flag file'
start action.cntr
End /* If */
End /* Do */
Do cntr = 1 to CfgCntr
If exist(disk.cntr) then do
'del' disk.cntr
End /* If */
End /* Do */
End /* Do While */
Exit /* To command line */
exist: /* sub-procedure to check if a file exists. retcode = 1 (exists) = 0 (not-exist) */
arg filename
rc = Stream(Filename, 'C', 'QUERY EXISTS')
If rc = '' then RetCode = 0
else Retcode = 1
Return(RetCode)