Solved IF VAR1 LEQ VAR2 Negative values issue

Mobile computing solutions Mini itx pfse...
December 3, 2015 at 04:44:21
Specs: Windows XP, HexaCore AMD FX-6100, 1400 MHz (7 x 200) / 4gb DDR
Hi can someone help with this ?

I have what might appear to be a simple problem, but it is only simple to those who know the answer!

I have counter file running that I set an offset count to avoid false positives for example I ping my website periodically to check it's online status bt I do not want to be alerted for short term outages, so I use my count down timer that scans every 20 seconds and the capped max stored in my VAR1 is 6, if my site appears offline briefly then the countdown begins once it reaches -6 then my script is meant to alert me, the problem is the minus (-6) is still treated as a positive number does anyone have ideas how to resolve this apart from using a higher number like (12) and counting down to zero (0)

I want to have the (-) minus offset if Possible ?

Regards


:: START

:: ########### MONITORING MY WEBSITE STATUS ###########
:: ----------------------------------------------------
:: ***** TEST DATA WEBSITE BELOW USE A KNOWN WEBSITE BELOW *****
ping -n 1 ftp.some-website.com > nul
echo Website STATUS NOTICE Offset Counter is "%webcnt1%"
if "%webcnt1%" leq "5" >> %ftplog% echo Website STATUS NOTICE Offset Counter is "%webcnt1%" "%Time%" "%Date%"
echo.
goto %errorlevel%
goto :cycle
:0
pathping 127.0.0.1 -n -q 1 -p 5000 >nul 2>&1
:: ----------------------------------------------------
:: Positive climb Prevents Temporary False Positives
if "%webcnt1%" geq "6" set webcnt1=5
set /a webcnt1=%webcnt1%+1
if "%webcnt1%" geq "3" (goto :webt) else (goto :cycle)
:: ----------------------------------------------------
cls
:webt
echo WEBSITE SOME-DOMAIN IS UP!
if "%down%"=="true" >> %ftplog% echo Website SOME-DOMAIN.com Back Online %time% %Date%
if "%down%"=="true" SAYSTATIC SOME-DOMAIN WEBSITE IS BACK ONLINE
if "%down%"=="true" echo SOME-DOMAIN WEBSITE IS BACK ONLINE
set down=false
goto :cycle

:1
pathping 127.0.0.1 -n -q 1 -p 5000 >nul 2>&1
>> %ftplog% echo Website STATUS NOTICE Offset Counter is "%webcnt1%" %time% %Date%
:: ----------------------------------------------------
:: Negative climb Prevents Temporary False Negatives
if "%webcnt1%" leq "-6" set webcnt1=-5
set /a webcnt1=%webcnt1%-1
if "%webcnt1%" leq "-3" (goto :webf) else (goto :cycle)
:: ----------------------------------------------------
cls
:webf
echo WEBSITE SOME-DOMAIN IS DOWN
if "%down%"=="false" >> %ftplog% echo Website SOME-DOMAIN.com Gone Offline %time% %Date%
if "%down%"=="false" SAYSTATIC SOME-DOMAIN WEBSITE HAS GONE OFFLINE
if "%down%"=="false" echo SOME-DOMAIN WEBSITE HAS GONE OFFLINE
set down=true

:cycle
:: ########### MONITORING MY WEBSITE STATUS ###########

:: END

If Dreams Come True Oleg Would be Famous so far he's very shy, so much for Being Famous ;) http://tinyurl.com/pnenqgb


See More: IF VAR1 LEQ VAR2 Negative values issue

Report •

#1
December 3, 2015 at 08:16:46
✔ Best Answer
This is one of those times where you shouldn't double quote your comparisons.
C:\>if -6 geq 5 echo Y

C:\>if "-6" geq "5" echo Y
Y

C:\>

How To Ask Questions The Smart Way


Report •

#2
December 3, 2015 at 11:09:50
OOPS (head bangs) thanks Razor will test.

Regards O

If Dreams Come True Oleg Would be Famous so far he's very shy, so much for Being Famous ;) http://tinyurl.com/pnenqgb


Report •

#3
December 3, 2015 at 12:18:06
Thank you Razor,
All fixed thanks to your great Answer I feel almost embarrassed like those times you have loo roll hanging out the back of your pants before realizing sums don't like "" quotes :p

Regards, Ort

If Dreams Come True Oleg Would be Famous so far he's very shy, so much for Being Famous ;) http://tinyurl.com/pnenqgb


Report •
Related Solutions


Ask Question