home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 274.lha / NazCron_v1.0 / NCAdd.rexx < prev    next >
OS/2 REXX Batch file  |  1989-08-06  |  2KB  |  91 lines

  1. /***********************/
  2. /* NCAdd.rexx          */
  3. /* 7/20/89 - Don Nafis */
  4. /***********************/
  5.  
  6. /* This script demonstrates loading the NazCron event list from Arexx,
  7.      using a CRONTAB file.  There is no real advantage to using this
  8.      method to load a new CRONTAB file other than to allow some pre-
  9.      processing of the file in the ARexx script.  Otherwise it would
  10.      be much faster to use the NEW_EVENT_FILE command to introduce a
  11.      new CRONTAB.  You could, of course, use this technique to load
  12.      multiple CRONTAB files, using ARexx to determine which file(s)
  13.      to load.
  14.  
  15.    Usage:
  16.      rx NCNew filename
  17.      where
  18.        filename must be the full file path of the new CRONTAB file.
  19.  */
  20.  
  21. /* Remove the comments below to trace this script. */
  22. /*--->trace results<---*/
  23.  
  24. options failat 20
  25.  
  26. arg crontabname
  27. if (crontabname == '') then
  28. do
  29.   say
  30.   say '  Usage:  rx NCAdd crontabfilename'
  31.   say
  32.   exit 20
  33. end
  34.  
  35. if (open(crontabfile,crontabname) ~= 1) then
  36.   do
  37.     say
  38.     say "  I could not find file: " || crontabname || "."
  39.     say
  40.     exit 20
  41.   end;
  42.  
  43.  
  44. address NAZCRON
  45.  
  46. cronrec = readln(crontabfile)
  47.  
  48. if (~EOF(crontabfile)) then
  49. do
  50.   say
  51.   say 'Adding NazCron statements from file: '||crontabname
  52.   say
  53. end
  54. else
  55. do
  56.   say '  NazCron event file '||crontabname||' is empty.'
  57.   say
  58.   close(crontabfile)
  59.   exit 5
  60. end
  61.  
  62. do while (~EOF(crontabfile))
  63.  
  64. /*
  65.  * This is where you would put your pre-processing code.
  66.  */
  67.  
  68.   'ADD_EVENT '||cronrec
  69.  
  70.   if (rc ~= 0) then
  71.   do
  72.     say '  NazCron ADD_EVENT failure.'
  73.     say
  74.     say '  ->'|| cronrec
  75.     say '  Return code: '|| rc
  76.     say
  77.     close(crontabfile)
  78.     exit 20
  79.   end
  80.   else
  81.   do
  82.     say '->'||cronrec
  83.     cronrec = readln(crontabfile)
  84.   end
  85. end
  86.  
  87. close(crontabfile)
  88. say
  89.  
  90. exit 0
  91.