KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Shell Script Test - strange %errorlevel% value

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
AlexL



Joined: 18 Jul 2006
Posts: 62
Location: Switzerland

PostPosted: Wed Jul 27, 2011 6:29 am    Post subject: Shell Script Test - strange %errorlevel% value Reply with quote

[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:
@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:
[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:
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
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed Jul 27, 2011 7:45 am    Post subject: Shell Script Test - strange %errorlevel% value Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AlexL



Joined: 18 Jul 2006
Posts: 62
Location: Switzerland

PostPosted: Wed Jul 27, 2011 8:35 am    Post subject: Re: Shell Script Test - strange %errorlevel% value Reply with quote

Yes, this did the trick!

Thanks a lot!

Alex
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed Jul 27, 2011 8:56 am    Post subject: Shell Script Test - strange %errorlevel% value Reply with quote

You are welcome !
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index