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

Macrovars not translated in params field of Shellscript

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



Joined: 19 May 2004
Posts: 151
Location: Belgium

PostPosted: Wed Aug 25, 2004 7:37 am    Post subject: Macrovars not translated in params field of Shellscript Reply with quote

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:
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
Back to top
View user's profile Send private message Visit poster's website
Marcus



Joined: 18 Nov 2002
Posts: 367

PostPosted: Thu Aug 26, 2004 1:50 am    Post subject: Reply with quote

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



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Thu Aug 26, 2004 1:59 am    Post subject: Reply with quote

Quote:
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
Back to top
View user's profile Send private message Visit poster's website
KS-Soft



Joined: 03 Apr 2002
Posts: 12792
Location: USA

PostPosted: Thu Aug 26, 2004 9:15 pm    Post subject: Reply with quote

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



Joined: 19 May 2004
Posts: 151
Location: Belgium

PostPosted: Wed Sep 01, 2004 2:31 am    Post subject: Reply with quote

great ! thx for the quick fixes
Back to top
View user's profile Send private message 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