home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
chang09m.zip
/
autochanx.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-08-29
|
4KB
|
122 lines
/*
AUTOCHANX.CMD
This is used to call CHANX (the news-exchange program) with the date that
CHANX was last called, so that only recent news is received.
*/
/* User settable constants for the Program */
ChangiPIDSpec = 'D:\APPS\NEWS\CHANGI.PID' /* Location of CHANGI.PID, when present */
ChanxFileSpec = 'D:\APPS\NEWS\CHANX.EXE' /* Location of CHANX.EXE */
HostNewsAddress = 'news.dircon.co.uk' /* Name of the news server */
Groups = 'D:\APPS\NEWS\NEWSRC' /* Name of file specifying which groups */
/* to collect */
MaxDays = 2 /* Maximum number of days to collect */
/* Should not exceed 27 */
/* Internal constants */
MonthDays.1 = 31 /* How many days in each month */
MonthDays.2 = 28
MonthDays.3 = 31
MonthDays.4 = 30
MonthDays.5 = 31
MonthDays.6 = 30
MonthDays.7 = 31
MonthDays.8 = 31
MonthDays.9 = 30
MonthDays.10 = 31
MonthDays.11 = 30
MonthDays.12 = 31
/* Load the system functions (REXXUTIL) */
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
/* Check to see if Changi the NNTP news server is running, by checking for the */
/* existence of the CHANGI.PID file. Changi must be running for Chanx to work. */
if STREAM( ChangiPIDSpec, 'c', 'Query exists' )=='' then
do
say "The Changi NNTP news server must be running for CHANX to work."
say "If Changi is running, then check the setting of the ChangiPIDSpec"
say "variable in the REXX script. The current value of ChangiPIDSpec"
say "is '"ChangiPIDSpec"'"
exit
end
/* The date command, Date('Based') returns the number of days since 01 January 0001 */
/* This makes it easy to get the difference between dates, in days */
/* Date('Ordered') returns the date in the form YY/MM/DD */
TodayBased = Date('Based') /* Get the Current Date */
TodayOrdered = Date('Ordered')
TodayTime = Time()
/* Get the last date that CHANX was called from an extended file attribute in */
/* CHANX.EXE */
result = SysGetEA( ChanxFileSpec, 'LASTRUN_ORDERED', 'LastOrdered' )
result = SysGetEA( ChanxFileSpec, 'LASTRUN_TIME', 'LastTime' ) + result
result = SysGetEA( ChanxFileSpec, 'LASTRUN_BASED', 'LastBased' ) + result
if (result \= 0) | (LastOrdered=='') then
do
say "Could not read extended attributes LASTRUN_BASED and LASTRUN_SORTED"
say "from file '"ChanxFileSpec"'. Assuming that this is the first"
say "time you are running this script."
/* Default action is to collect the last MaxDays lot of news */
LastBased = 0
LastTime = '000000'
LastSorted = ' '
end
/*
If more than MaxDays have passed since the last collection of news, then
collect only the last MaxDays lot of news.
*/
if (TodayBased - LastBased > MaxDays) then
do
PARSE VAR TodayOrdered Year '/' Month '/' Day
/* Subtract MaxDays from Today's date */
Day = Day - MaxDays
if Day <= 0 then
do
Month = Month - 1;
if Month <= 0 then do
Month = 12
Year = Year - 1
end
Day = MonthDays.Month - MaxDays;
end
LastSorted = Year''Month''Day
LastTime = TodayTime
end
else do
PARSE VAR LastOrdered Year '/' Month '/' Day
LastSorted = Year''Month''Day
end
/* Split the time into hour minute and second portions */
PARSE VAR LastTime Hour ':' Minute ':' Seconds
/* Call chanx with the appropriate parameters, remove the say to perform the function */
ChanxFileSpec HostNewsAddress Groups LastSorted Hour''Minute''Seconds
/* Update Chanx's Extended Attributes */
result = SysPutEA( ChanxFileSpec, 'LASTRUN_ORDERED', TodayOrdered )
result = SysPutEA( ChanxFileSpec, 'LASTRUN_TIME', TodayTime ) + result
result = SysPutEA( ChanxFileSpec, 'LASTRUN_BASED', TodayBased ) + result