home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / cenvi29.zip / RUNTIME.CMD < prev    next >
OS/2 REXX Batch file  |  1994-03-08  |  2KB  |  65 lines

  1. @echo off
  2. REM ********************************************************
  3. REM *** RunTime.cmd - Execute commands at supplied time. ***
  4. REM *** ver.1         The beginnings of a scheduler.     ***
  5. REM ********************************************************
  6.  
  7. ECHO Command: %2 %3 %4 %5 %6 %7 %8 %9
  8. CEnvi %0.cmd %1
  9. GOTO CENVI_EXIT
  10.  
  11. // define TIME_CHECK_DELAY for how long to delay in between each time
  12. // checking if the RunTime has come yet.  This time is in milliseconds so
  13. // 1000 is 1 second. This time is not exact so setting to 60000 (60 seconds)
  14. // might miss an entire minute. Less then 100 would probably take up more
  15. // processor time than you want, but still not very much
  16. #define  TIME_CHECK_DELAY  5000  // check every 5 seconds
  17.  
  18. main(argc,argv)
  19. {
  20.    if ( argc < 2  ||  2 != sscanf(argv[1],"%d:%d",RunHour,RunMinute)
  21.      || RunHour < 0  ||  23 < RunHour
  22.      || RunMinute < 0  ||  59 < RunMinute ) {
  23.       Instructions();
  24.    } else {
  25.       printf("Scheduled time: %02d:%02d:00\n",RunHour,RunMinute);
  26.       // Loop here forever until RunHour:RunMinute comes along, then exit
  27.       DisplayedSecond = -1; // force current time to print
  28.       do {
  29.          GetCurrentTime(CurrentHour,CurrentMinute,CurrentSecond);
  30.          if ( CurrentSecond != DisplayedSecond )
  31.             printf("\rCurrent Time:   %02d:%02d:%02d",
  32.                    CurrentHour,CurrentMinute,DisplayedSecond=CurrentSecond);
  33.          suspend(TIME_CHECK_DELAY);
  34.       } while ( CurrentHour != RunHour  ||  CurrentMinute != RunMinute );
  35.       printf("\n");
  36.    }
  37. }
  38.  
  39. GetCurrentTime(hour,minute,second)
  40. {
  41.    now = localtime(time());
  42.    hour = now.tm_hour;
  43.    minute = now.tm_min;
  44.    second = now.tm_sec;
  45. }
  46.  
  47. Instructions()
  48. {
  49.    printf("\n");
  50.    printf("RunTime - Perform a command, with up to 7 parameters, at a specified time.\n");
  51.    printf("\n");
  52.    printf("SYNTAX: RunTime <hour>:<minute> [Command] [parm1] [parm2] [etc...]\n");
  53.    printf("\n");
  54.    printf("Where: hour   - hour of day (in 24-hour format) to run command; range 0 - 23\n");
  55.    printf("       minute - minute of hour to run command: range 0 - 59\n");
  56.    printf("\n");
  57.    printf("Examples: RunTime 14:30 chkdsk c: /f   - run chkdsk at 2:30 PM\n");
  58.    printf("          RunTime 0:00                 - pause computer until midnight\n");
  59.    printf("\n");
  60. }
  61.  
  62. :CENVI_EXIT
  63. ECHO %2 %3 %4 %5 %6 %7 %8 %9
  64. %2 %3 %4 %5 %6 %7 %8 %9
  65.