Macrovars not translated in params field of Shellscript

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
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Macrovars not translated in params field of Shellscript

Post by plambrecht »

Hi,

I'm having troubles with a shellscript...
I'm creating a script that return a deltavalue between result and lastresult.
it needs to run on RMA's so i'm creating it as a shell script (windows).
I have a test called "Cdrive" that checks the freespace.

Next I created a new test, that has these settings
Params %::Cdrive::LastReply% %::Cdrive::Reply% 10
Enabled Translate Macros

and runs this script:

Code: Select all

Option Explicit

const statusAlive       = "Host is alive:"
const statusDead        = "No answer:"
const statusUnknown     = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk          = "Ok:"
const statusBad         = "Bad:"
const statusBadContents = "Bad contents:"

If cStr("%LastReply%") = cStr("%" & "LastReply" & "%") then
  WScript.StdOut.Write "scriptres:" & StatusBad & "Please enable \'Translate Macros\' on the Test Properties"
  WScript.Quit(0)
End If

Set objArgs = WScript.Arguments
If objArgs.Count<3 Then
  WScript.StdOut.Write "scriptres:" & statusUnknown & "Unsufficient Parameters"
Else
  LastReply=objArgs(0)
  Reply=objArgs(1)
  MaxDelta=objArgs(2)
  WScript.StdOut.Write "scriptres:OK:(" & LastReply & ")(" & Reply & ")(" & MexDelta & ")"
  If LastReply>0 Then
    Delta=(LastReply-Reply)/LastReply*100
    If cInt(Delta) > cInt(MaxDelta) Then
      WScript.StdOut.Write "scriptres:BAD:" & Delta & " %"
    Else
      WScript.StdOut.Write "scriptres:OK:" & Delta & " %"
    End If
  Else
    WScript.StdOut.Write "scriptres:Bad contents:LastReply can't be zero"
  End If
End If
Set objArgs = Nothing
The problem now is, that the macrovars in the params field are not translated to their values, but they remain the text.

Can you try to reproduce this ?
I'm using v4.60, testing it localy without RMA

thx

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

Post by Marcus »

The macro's are translated, and passed to your script. But since vbscript does not know anything about HostMonitor, your have to read the values as if they are passed from the command line :D
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

But since vbscript does not know anything about HostMonitor, your have to read the values as if they are passed from the command line
You are right.
But there is another problem - HostMonitor does not support test related variables in the "Params" field, it supports global macro variables.
Probably we can improve this.. I will check tomorrow

Regards
Alex
KS-Soft
Posts: 12821
Joined: Wed Apr 03, 2002 6:00 pm
Location: USA
Contact:

Post by KS-Soft »

Ok, update available at www.ks-soft.net/download/hm461.zip
Now you may use test related variables as params.
Do not forget to change your script (it should use command line parameters).

Regards
Alex
User avatar
plambrecht
Posts: 151
Joined: Wed May 19, 2004 8:11 am
Location: Belgium
Contact:

Post by plambrecht »

great ! thx for the quick fixes
Post Reply