Exectute External Program and Global Variables

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
r00t-shell
Posts: 9
Joined: Tue Jan 09, 2007 8:15 am

Exectute External Program and Global Variables

Post by r00t-shell »

Execution of global variables does not seem to work when you execute a external program.

Can this be confirmed?

I am trying to use &Fullpath&. I have all my test structured as such that top folder is ofcourse ROOT, but next one is my Customer Code, and Third is location. So with the passing of this variable i will be able to create tickets by customer, location, server, test.

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

Re: Exectute External Program and Global Variables

Post by KS-Soft Europe »

r00t-shell wrote:Execution of global variables does not seem to work when you execute a external program.
Do you have problems with Global macro variables ( http://www.ks-soft.net/hostmon.eng/mfra ... m#udvmacro ) or with test ralated varibles ( http://www.ks-soft.net/hostmon.eng/mfra ... .htm#macro )
r00t-shell wrote:Can this be confirmed?
Sorry, could not reproduce the problem. Everything should work if you specify string like this:

Code: Select all

C:\Temp\some_program.exe %udv_some_global_variable% %TestName% %Reply%
r00t-shell wrote:I am trying to use &Fullpath&. I have all my test structured as such that top folder is ofcourse ROOT, but next one is my Customer Code, and Third is location. So with the passing of this variable i will be able to create tickets by customer, location, server, test.
Could you provide an example of the string, you have specified into "Command Line" box of "Action properties" window? What parameters do you want to pass to this program? Does it work if you run it from the command line? What exact macro variables do you use?

Regards,
Max
r00t-shell
Posts: 9
Joined: Tue Jan 09, 2007 8:15 am

Post by r00t-shell »

Problem is with test related variables.

Here is what i am entering for the test with external program:

C:\Master-ReadLog.exe %Fullpath% mastertest

I have tested this with command line with the following:

C:\Master-ReadLog.exe root\TEST\MAIN mastertest

It will return what i exepect,ed and it's returning the proper error level ( tested with batch )

Now, if i use:

C:\Master-ReadLog.exe \root\TEST\MAIN mastertest

I will return the proper error code for the reply.

It's like it won't accept the test varible for the argument. I've tried everything with or without quotes.

Thanks,
r00t-shell
Posts: 9
Joined: Tue Jan 09, 2007 8:15 am

Post by r00t-shell »

Followup:

I cut all code out of the program and made it do the following.

Take the argument passed to the program, and write it to a test file.
It will just return the variable name passed, not the contents of the variable.

"C:\MASTER-READLOG.EXE" %FullPath%

The above is the path to the external program test. In my output.txt file i just receieve %FullPath%, rather than \root\TESST\main as i would have hoped.
Could you provide an example of the string, you have specified into "Command Line" box of "Action properties" window? What parameters do you want to pass to this program? Does it work if you run it from the command line? What exact macro variables do you use?
maybe i wasn't clear in this part at first. What i'm doing is not part of the "Action Properties" window. I am trying to pass these Test Varibles to a external program as a TEST Itself - NOT as an action which is a result of a bad test.
Any ideas?
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

So, are we talking about External Test ( http://www.ks-soft.net/hostmon.eng/mfra ... m#execheck )? Sorry, I thouht You have problems with "Execute external program" action.

Macro varables are not allowed in "External program" test method. You should specify exact values as parameters, not variables. However, you may use macro variables in "Execute external program" action ( http://www.ks-soft.net/hostmon.eng/mfra ... htm#actPrg ).

Regards,
Max
r00t-shell
Posts: 9
Joined: Tue Jan 09, 2007 8:15 am

Post by r00t-shell »

Is this just something that can't be added? I think it would serve many benefits.

The reason i'm looking for this is so that i can know where my exectued program should look for a log file without having to create a different master test for every customer.

What my program does it this. It takes the folder path, splits it, removes root, takes the next folder as the customer id, and the next as the customer location.

It then takes those variables and checks a specific folder structure for each customer looking for a log file. If there is a logfile, it raises error level to 1 which triggers a seperate program that will enumerate all the failed tests in that log file and create a single ticket for all issues.

Anyhow,
KS-Soft
Posts: 13012
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

You cannot use variables as parameters of the test because you may specify such parameters directly in Test Properties dialog.
We plan to change this behaviour as part of big "templates" task. I don't think this will be done before version 7

Regards
Alex
apoxxo
Posts: 1
Joined: Tue Jan 23, 2007 4:30 am

Post by apoxxo »

KS-Soft wrote:You cannot use variables as parameters of the test because you may specify such parameters directly in Test Properties dialog.
Where do i find the specification of the parameters for the "external test" elsewhere as in row "External Program"? I don't see anything related to parameters?!

I'm also interested in passing of macro variables to an external program to deliver the current date to a program which returns an errorlevel when finding a specific text in a logfile.

External Program:
"D:\embit\Batch\Tools\CEBuildTools.exe" FindInFile2 "D:\embit\_PRODUKTIVSYSTEM_\_WebDaten_\RDF_aktuell\_Status_.txt" "FTP-Transfer fertig: %dd%.%mm%.%yyyy%"

(by the way: cannot be done with "Text Log" test, as some re-calculation of the date is necessary, which is done in CEBuildTools.exe)

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

Post by KS-Soft Europe »

apoxxo wrote:Where do i find the specification of the parameters for the "external test" elsewhere as in row "External Program"? I don't see anything related to parameters?!
There is nothing special in "External Program" test parameters. You just should specify external program name into "External program" input box and add parameters, separated by space, like:

Code: Select all

some_program.exe param1 param2 ... etc.
apoxxo wrote:I'm also interested in passing of macro variables to an external program to deliver the current date to a program which returns an errorlevel when finding a specific text in a logfile.

External Program:
"D:\embit\Batch\Tools\CEBuildTools.exe" FindInFile2 "D:\embit\_PRODUKTIVSYSTEM_\_WebDaten_\RDF_aktuell\_Status_.txt" "FTP-Transfer fertig: %dd%.%mm%.%yyyy%"
As Alex wrote above, you cannot use any variables as parameters of the "External Program" test. However, I would suggest you following solution. You should create simple .bat file like the following:

Code: Select all

@echo off
rem %1 - Log file name

call C:\get_date.bat
D:\embit\Batch\Tools\CEBuildTools.exe FindInFile2 "%~1" "FTP-Transfer fertig: %Day%.%Month%.%Year%"
To make it work you should create new "External Program" test and specify following values into "External Program" input box:

Code: Select all

D:\bat_file_name.bat "D:\embit\_PRODUKTIVSYSTEM_\_WebDaten_\RDF_aktuell\_Status_.txt"
As you may see, foregoing .bat file requires to invoke another .bat file, called get_date.bat. This file takes the system date and parse it into %Year%, %Month%, %Day% variables. Here is the listing:

Code: Select all

REM get_date.bat Script retrieves system date and parse it.
REM Output variables:
REM %Year%, %Month%, %Day%
REM %iDate%,%sDate% - Date Separators from registry

rem Select date
:: Export registry's date format settings to a temporary file
START /W REGEDIT /E _TEMP.REG "HKEY_CURRENT_USER\Control Panel\International"

:: Read the exported data
FOR /F "tokens=2* delims==" %%A IN ('TYPE _TEMP.REG ^| FIND /I "iDate"') DO SET iDate=%%A
FOR /F "tokens=2* delims==" %%A IN ('TYPE _TEMP.REG ^| FIND /I "sDate"') DO SET sDate=%%A
DEL _TEMP.REG

SET iDate=%iDate:"=%
SET sDate=%sDate:"=%

IF %iDate%==0 FOR /F "TOKENS=1-4* DELIMS=%sDate%" %%A IN ('DATE/T') DO (
	SET Year=%%C
	SET Month=%%A
	SET Day=%%B
)
IF %iDate%==1 FOR /F "TOKENS=1-4* DELIMS=%sDate%" %%A IN ('DATE/T') DO (
	SET Year=%%C
	SET Month=%%B
	SET Day=%%A
)
IF %iDate%==2 FOR /F "TOKENS=1-4* DELIMS=%sDate%" %%A IN ('DATE/T') DO (
	SET Year=%%A
	SET Month=%%B
	SET Day=%%C
)

:: Remove the day of week if applicable
FOR %%A IN (%Year%)  DO SET Year=%%A
FOR %%A IN (%Month%) DO SET Month=%%A
FOR %%A IN (%Day%)   DO SET Day=%%A
So, you just should adjust file names and pathes to reach desired behavior.
apoxxo wrote:(by the way: cannot be done with "Text Log" test, as some re-calculation of the date is necessary, which is done in CEBuildTools.exe)
If you explain how exactly you want to parse log file, I will suggest you the appropriate solution.

Regards,
Max
Post Reply