WaitUntil - batch command replacement for scheduler
-
- Posts: 83
- Joined: Fri Aug 09, 2013 12:43 am
WaitUntil - batch command replacement for scheduler
I'd like to take some of the applications in the office out of the Windows Scheduler, and just put it in a batch file that waits until a specified time.
I already use Timeout for certain tasks. And there are variations of this, out on the web.
But I haven't found anything like a WaitUntil command. I'm pretty sure I could build it in Harbour/Fivewin, within a week. But since there doesn't seem to be an existing command out there, or maybe it's more difficult than it seems on the surface.
Can anyone think of a reason that an executable that runs like
WaitUntil <Day> <Time Range>
e.g.
WaitUntil Mon "13:50" "14:10"
would be difficult?
I already use Timeout for certain tasks. And there are variations of this, out on the web.
But I haven't found anything like a WaitUntil command. I'm pretty sure I could build it in Harbour/Fivewin, within a week. But since there doesn't seem to be an existing command out there, or maybe it's more difficult than it seems on the surface.
Can anyone think of a reason that an executable that runs like
WaitUntil <Day> <Time Range>
e.g.
WaitUntil Mon "13:50" "14:10"
would be difficult?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 83
- Joined: Fri Aug 09, 2013 12:43 am
Re: WaitUntil - batch command replacement for scheduler
Unfortunately, it doesn't address the specification of a specific time. These are just variations of timeout, where you specify the number of seconds.
I'd want a child program or batch to run, e.g. at 11:15 am, regardless of when the parent calling batch starts. So we don't know the number of seconds, in advance.
There has to be some reason why a utility that specifies the time to run something is so rare. There must be some inherent difficulty, or maybe people prefer to use the windows scheduler because it's already there.
I think I just have to hack around, do some coding, and become more familiar with the problem.
Thanks, Antonio.
I'd want a child program or batch to run, e.g. at 11:15 am, regardless of when the parent calling batch starts. So we don't know the number of seconds, in advance.
There has to be some reason why a utility that specifies the time to run something is so rare. There must be some inherent difficulty, or maybe people prefer to use the windows scheduler because it's already there.
I think I just have to hack around, do some coding, and become more familiar with the problem.
Thanks, Antonio.
-
- Posts: 83
- Joined: Fri Aug 09, 2013 12:43 am
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: WaitUntil - batch command replacement for scheduler
D.
You can build it using FWH this way:
example of use (from cmd.exe)
tarry 21:26
tarry.prg
You can build it using FWH this way:
example of use (from cmd.exe)
tarry 21:26
tarry.prg
Code: Select all
#include "FiveWin.ch"
function Main( cTime )
if cTime != nil
while Time() < cTime
SysRefresh()
end
// DoWhatever()
endif
return nil
-
- Posts: 83
- Joined: Fri Aug 09, 2013 12:43 am
Re: WaitUntil - batch command replacement for scheduler
Thanks Antonio,
But unfortunately, it's not exactly what I'm trying to build.
Anyway, I'm very close. I'll share the code shortly.
But unfortunately, it's not exactly what I'm trying to build.
Anyway, I'm very close. I'll share the code shortly.
Antonio Linares wrote:D.
You can build it using FWH this way:
example of use (from cmd.exe)
tarry 21:26
tarry.prgCode: Select all
#include "FiveWin.ch" function Main( cTime ) if cTime != nil while Time() < cTime SysRefresh() end // DoWhatever() endif return nil
-
- Posts: 83
- Joined: Fri Aug 09, 2013 12:43 am
Re: WaitUntil - batch command replacement for scheduler
Hi Antonio,
This is what I was (unsuccessfully) trying to describe.
https://raw.githubusercontent.com/HBEnt ... tUntil.prg
The executable WaitUntil.exe is also on that hub.
I haven't fully tested it in more than 4 circumstances yet, but the syntax is
WaitUntil <Day> <Time>
So, in order to wait until Friday at 1:15 pm, you would type
WaitUntil "Friday" "13:15:00"
Regards,
This is what I was (unsuccessfully) trying to describe.
https://raw.githubusercontent.com/HBEnt ... tUntil.prg
The executable WaitUntil.exe is also on that hub.
I haven't fully tested it in more than 4 circumstances yet, but the syntax is
WaitUntil <Day> <Time>
So, in order to wait until Friday at 1:15 pm, you would type
WaitUntil "Friday" "13:15:00"
Regards,
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: WaitUntil - batch command replacement for scheduler
This works for me.
waituntil.prg
waituntil.prg
Code: Select all
#include "fivewin.ch"
function Main()
local cDay := HB_ARGV( 1 )
local nSec := TIMETOSEC( HB_ARGV( 2 ) )
local n
do while !( CDOW( Date() ) = cDay )
Sleep( ( 86401 - Seconds() ) * 1000 )
enddo
do while ( n := Seconds() ) < nSec
Sleep( ( nSec - n ) * 1000 )
enddo
? "Start work"
return nil
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 83
- Joined: Fri Aug 09, 2013 12:43 am
Re: WaitUntil - batch command replacement for scheduler
Looks good, I'll put it through its paces, thanks.
nageswaragunupudi wrote:This works for me.
waituntil.prg
Code: Select all
#include "fivewin.ch" function Main() local cDay := HB_ARGV( 1 ) local nSec := TIMETOSEC( HB_ARGV( 2 ) ) local n do while !( CDOW( Date() ) = cDay ) Sleep( ( 86401 - Seconds() ) * 1000 ) enddo do while ( n := Seconds() ) < nSec Sleep( ( nSec - n ) * 1000 ) enddo ? "Start work" return nil