Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

iff test condition problem

Jul
46
2
I'm trying to "build" a batch that's a kind of Linux cron job, with the schedules inside the batch.
From Monday to Friday, a command runs at 7:00 AM, 1:00 PM, and 8:00 PM, while on Saturday and Sunday, it runs only at 1:00 PM.
I'm trying every possible combination, but I can't get the iff to work (bold row, hour 24h format, tDAY = 1 - Sunday).

@echo off

do forever

set tDAY=%_dowi
set tHOUR=%_hour%%_minute%%_second%

printf "{TEST} %s %02d/%02d/%4d %02d:%02d:%02d - START\n" %_DOW %_DAY %_MONTH %_YEAR %_HOUR %_MINUTE %_SECOND
printf "{TEST} %s\n" %tHOUR
echo %@eval[%tHOUR] %@eval[130000]

iff %@eval[%tHOUR] ge %@eval[200000] then
if %tDAY% == 1 .or. %tDAY% == 2 .or. %tDAY% == 3 .or. %tDAY% == 4 .or. %tDAY% == 5 (
printf "{TEST} Wait until 07:00\n"
delay until 07:00
rem Commands to execute
printf "{TEST} Command execute 07:00\n"
)
elsiff %@eval[%tHOUR] ge %@eval[130000] then
if %tDAY% == 1 .or. %tDAY% == 2 .or. %tDAY% == 3 .or. %tDAY% == 4 .or. %tDAY% == 5 .or. %tDAY% == 6 (
printf "{TEST} Wait until 20:00\n"
delay until 20:00
rem Commands to execute
printf "{TEST} Command execute 20:00\n"
)
elsiff %@eval[%tHOUR] ge %@eval[070000] then
printf "{TEST} Wait until 13:00\n"
delay until 13:00
rem Commands to execute
printf "{TEST} Command execute 13:00\n"
endiff

printf "{TEST} %s %02d/%02d/%4d %02d:%02d:%02d - STOP\n" %_DOW %_DAY %_MONTH %_YEAR %_HOUR %_MINUTE %_SECOND
printf "%s\n" %@repeat[=,80]

enddo


Any hint?
 
You didn't say what the error message was, but you do have a typo in this line:

elsiff %@eval[%tHOUR] ge %@eval[130000] then

That should be elseiff.
 
Last edited:
That's probably the problem, but the strange thing is that I didn't have any errors, it's just as if the iff wasn't being executed. The output (with the elsiff error)

{TEST} Sun 03/05/2026 18:36:45 - START
{TEST} 183645
183645 130000
{TEST} Sun 03/05/2026 18:36:45 - STOP
================================================================================
{TEST} Sun 03/05/2026 18:36:45 - START
{TEST} 183645
183645 130000
{TEST} Sun 03/05/2026 18:36:45 - STOP
================================================================================
{TEST} Sun 03/05/2026 18:36:45 - START
{TEST} 183645
183645 130000
{TEST} Sun 03/05/2026 18:36:45 - STOP
================================================================================
 
I can't test your exact script, but if I do something similar with the typo, I get an error message to the effect the "elsiff" is not a valid command.

What happens if you run something like

Code:
iff a eq a then
  echo yes
elsiff a ne a then
  echo no
endiff

That definitely gives me an error message.
 
Back
Top