home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / c / crashmailv1.22reg.lha / CrashMail / rexx / AnnounceAutoAdd.rexx next >
OS/2 REXX Batch file  |  1995-02-18  |  2KB  |  109 lines

  1. /*
  2.  
  3.    AnnounceAutoAdd.rexx 1.0 by Johan Billing 1994
  4.  
  5.    This script will scan CrashMail's logfile and announce any auto-added
  6.    and forward-requested areas in an area of your choice. 
  7.  
  8. */
  9.  
  10. /* Configuring */
  11.  
  12. logfile = "Work:UMS/CrashMail/CrashMail.log"
  13. crashwrite = "Work:UMS/CrashMail/CrashWrite"
  14. announcearea = "KCC_INFO"
  15. node = "2:200/207.6"
  16.  
  17. /* Script starts here! */
  18.  
  19. options results
  20.  
  21. lastline=""
  22. areas=0
  23.  
  24. IF ~SHOW(Libraries,'rexxsupport.library') THEN
  25.     IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN EXIT
  26.  
  27. /* Start reading the log... */
  28.  
  29. call open('file',logfile,'R')
  30.  
  31. /* Skipping the part we have read already */
  32.  
  33. pos=0
  34.  
  35. do while ~eof('file')
  36.  str=readln('file')
  37.  if substr(str,21)="AnnounceAutoAdd.rexx logscan" then pos=seek('file',0,'Current')
  38. end
  39.  
  40. /* If we didn't find the string, the logfile must have been cleared and we
  41.    should read it from the beginning */
  42.  
  43. if substr(str,21)~="AnnounceAutoAdd.rexx logscan" then do
  44.  call seek('file',pos,'B')
  45. end
  46.  
  47. /* Scan for auto-added and forward-requested areas */
  48.  
  49. do while ~eof('file')
  50.  str = readln('file')
  51.  if str~="" then lastline=str
  52.  
  53.  area=""
  54.  
  55.  if substr(str,21,12)="Unknown area" then do
  56.   if pos("auto-adding",str)~=0 then do
  57.    realline=substr(str,21)
  58.    parse var realline 'Unknown area ' area ' '
  59.   end
  60.  end
  61.  
  62.  if substr(str,21,8)="AreaFix:" then do
  63.   if pos("requested from",str)~=0 then do
  64.    realline=substr(str,21)
  65.    parse var realline 'AreaFix: ' area ' '
  66.    area=area || ' (AreaFix forward-request)'
  67.   end
  68.  end
  69.  
  70.  if area~="" then do
  71.   if areas=0 then do
  72.    call open('outfile','T:AnnounceAutoAdd.tmp','W')
  73.    call writeln('outfile','New areas:')
  74.    call writeln('outfile','')
  75.   end
  76.  
  77.   call writeln('outfile',' 'area)
  78.   areas=areas+1
  79.  
  80.  end
  81. end
  82.  
  83. call close('file')
  84.  
  85. /* Write mark to logfile */
  86.  
  87. call open('file',logfile,'A')
  88. rawdate=date('n')
  89. date=left(rawdate,2) || "-" || substr(rawdate,4,3) || "-" || substr(rawdate,10,2)
  90. call writeln('file',date || " " || time('n') || "  " || "AnnounceAutoAdd.rexx logscan")
  91. close('file')
  92.  
  93. /* No areas found? */
  94.  
  95. if areas=0 then exit
  96.  
  97. /* Close tempfile */
  98.  
  99. call writeln('outfile','')
  100. call close('outfile')
  101.  
  102. /* *** WRITING *** */
  103.  
  104. address command crashwrite 'FN "CrashMail" FA 'node' TN "All" TA 'node' SUBJ "New areas" ORIGIN "Yet another interesting message" AREA "'announcearea'" T:AnnounceAutoAdd.tmp'
  105.  
  106. /* Yes, the line is VERY long... */
  107.  
  108. call delete('T:AnnounceAutoAdd.tmp') 
  109.