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 >
Wrap
OS/2 REXX Batch file
|
1994-03-08
|
2KB
|
65 lines
@echo off
REM ********************************************************
REM *** RunTime.cmd - Execute commands at supplied time. ***
REM *** ver.1 The beginnings of a scheduler. ***
REM ********************************************************
ECHO Command: %2 %3 %4 %5 %6 %7 %8 %9
CEnvi %0.cmd %1
GOTO CENVI_EXIT
// define TIME_CHECK_DELAY for how long to delay in between each time
// checking if the RunTime has come yet. This time is in milliseconds so
// 1000 is 1 second. This time is not exact so setting to 60000 (60 seconds)
// might miss an entire minute. Less then 100 would probably take up more
// processor time than you want, but still not very much
#define TIME_CHECK_DELAY 5000 // check every 5 seconds
main(argc,argv)
{
if ( argc < 2 || 2 != sscanf(argv[1],"%d:%d",RunHour,RunMinute)
|| RunHour < 0 || 23 < RunHour
|| RunMinute < 0 || 59 < RunMinute ) {
Instructions();
} else {
printf("Scheduled time: %02d:%02d:00\n",RunHour,RunMinute);
// Loop here forever until RunHour:RunMinute comes along, then exit
DisplayedSecond = -1; // force current time to print
do {
GetCurrentTime(CurrentHour,CurrentMinute,CurrentSecond);
if ( CurrentSecond != DisplayedSecond )
printf("\rCurrent Time: %02d:%02d:%02d",
CurrentHour,CurrentMinute,DisplayedSecond=CurrentSecond);
suspend(TIME_CHECK_DELAY);
} while ( CurrentHour != RunHour || CurrentMinute != RunMinute );
printf("\n");
}
}
GetCurrentTime(hour,minute,second)
{
now = localtime(time());
hour = now.tm_hour;
minute = now.tm_min;
second = now.tm_sec;
}
Instructions()
{
printf("\n");
printf("RunTime - Perform a command, with up to 7 parameters, at a specified time.\n");
printf("\n");
printf("SYNTAX: RunTime <hour>:<minute> [Command] [parm1] [parm2] [etc...]\n");
printf("\n");
printf("Where: hour - hour of day (in 24-hour format) to run command; range 0 - 23\n");
printf(" minute - minute of hour to run command: range 0 - 59\n");
printf("\n");
printf("Examples: RunTime 14:30 chkdsk c: /f - run chkdsk at 2:30 PM\n");
printf(" RunTime 0:00 - pause computer until midnight\n");
printf("\n");
}
:CENVI_EXIT
ECHO %2 %3 %4 %5 %6 %7 %8 %9
%2 %3 %4 %5 %6 %7 %8 %9