Shell Script Test - strange %errorlevel% value

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
AlexL
Posts: 62
Joined: Tue Jul 18, 2006 9:56 am
Location: Switzerland

Shell Script Test - strange %errorlevel% value

Post by AlexL »

[AHM v. 8.86, under Windows 2003 and 7]

I am trying to compare two files (I cannot use the File Compare test because one of the files has to be dynamically created by the test itself).
My script is this:

Code: Select all

@echo off
FC c:\aaa.txt c:\bbb.txt > nul
IF %errorlevel% == 0 (echo ScriptRes:OK:%errorlevel%) Else (echo ScriptRes:Bad:%errorlevel%)
If I execute it outside HostMonitor, it gives correct results. However, if I execute it under HM, for example under the Script Manager, with "Let's try", I get a "Bad" result even if I compare a file with itself:

Code: Select all

[13:38:38] HostMonitor is going to execute "TestErrorlevel" script ...
[13:38:38] Script executed, correct result received:
----------
- Status: Bad
- Reply: -1
----------
If instead of a file compare I have a

Code: Select all

dir c:\aaa.txt > nul
the results are correct. But again, in the command window the script with FC does work correctly.

What could it be?

TIA

Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Shell Script Test - strange %errorlevel% value

Post by KS-Soft Europe »

Looks like FC utility does not work when HostMonitor uses Windows "pipes".
Solution: you may add SScript_UseWindowsPipe=0 line into [Misc] section of hostmon.ini file and restart HostMonitor.
Note: in such case some scripts will use more system resources.
AlexL
Posts: 62
Joined: Tue Jul 18, 2006 9:56 am
Location: Switzerland

Re: Shell Script Test - strange %errorlevel% value

Post by AlexL »

Yes, this did the trick!

Thanks a lot!

Alex
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Shell Script Test - strange %errorlevel% value

Post by KS-Soft Europe »

You are welcome !
Post Reply