Reading the output from an exe

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
Quantum
Posts: 56
Joined: Thu May 06, 2004 6:04 pm

Reading the output from an exe

Post by Quantum »

LOL, yep another one. Sorry

I want to have a test that looks at the output from an external program. However this output is not just an errorlevel.

Example.
you execute c:\myapp.exe

On the screen it displays the following

Quantum's New App details
-------------------------------
User Count = 6
Date Engine Started = 23/5/04
Data Waiting to Write = 123,455K
So, what I want to be able to do is read in a part of each line into a variable and then make a comparison to that variable. I quess what I am tring to do is a test like if 25 < User count then test = BAD


I am not expecting hostmon to do this, I simply wanted to know if anyone had any cleaver ideas on this, even a program that could split the different elements of the programs' output into a few seperate files.


Hope this is understandable.

Q[/quote]
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Looks like you need to use Active Script or better Shell Script test method.
http://www.ks-soft.net/hostmon.eng/mfra ... htm#script
http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell

Regards
Alex
User avatar
Marcus
Posts: 367
Joined: Mon Nov 18, 2002 6:00 pm

Post by Marcus »

I am not expecting hostmon to do this, I simply wanted to know if anyone had any cleaver ideas on this, even a program that could split the different elements of the programs' output into a few seperate files.
Redirect the output to a file (">") and use a for statement on the file. If you redirect the output to the file 'temp.txt', the following code will show the number after the 'User Count =' line.....

Redirect: c:\myapp.exe > temp.txt

Code: Select all

@echo off
for /f "eol=; tokens=1* delims=" %%i in (temp.txt) do (call :ShowUserCount %%i)
goto :EOF

:ShowUserCount
 if /I "%1 %2" == "User Count" echo %3
goto :EOF
This means you have the count available (%3 in ShowUserCount function), which means you can create a script which does all the logic for you (and report the result back to HostMonitor).
Quantum
Posts: 56
Joined: Thu May 06, 2004 6:04 pm

Post by Quantum »

Thanks Marcus

This looks like a batch file to me, is that the case or is it VB script.

Sorry not a progammer :)
-Q
User avatar
Marcus
Posts: 367
Joined: Mon Nov 18, 2002 6:00 pm

Post by Marcus »

It's a batch file 8)
Quantum
Posts: 56
Joined: Thu May 06, 2004 6:04 pm

Post by Quantum »

Thanks

:D

-Q
Post Reply