View previous topic :: View next topic |
Author |
Message |
Quantum
Joined: 06 May 2004 Posts: 56
|
Posted: Tue Jul 13, 2004 10:12 am Post subject: Reading the output from an exe |
|
|
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.
Quote: |
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] |
|
Back to top |
|
|
KS-Soft
Joined: 03 Apr 2002 Posts: 12793 Location: USA
|
|
Back to top |
|
|
Marcus
Joined: 18 Nov 2002 Posts: 367
|
Posted: Wed Jul 14, 2004 9:37 am Post subject: |
|
|
Quote: | 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: | @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). |
|
Back to top |
|
|
Quantum
Joined: 06 May 2004 Posts: 56
|
Posted: Mon Aug 02, 2004 5:13 am Post subject: |
|
|
Thanks Marcus
This looks like a batch file to me, is that the case or is it VB script.
Sorry not a progammer
-Q |
|
Back to top |
|
|
Marcus
Joined: 18 Nov 2002 Posts: 367
|
Posted: Mon Aug 02, 2004 5:23 am Post subject: |
|
|
It's a batch file |
|
Back to top |
|
|
Quantum
Joined: 06 May 2004 Posts: 56
|
Posted: Mon Aug 02, 2004 5:31 am Post subject: |
|
|
Thanks
-Q |
|
Back to top |
|
|
|