Server Management - Systems Insight Manager
1836374 Members
2228 Online
110100 Solutions
New Discussion

Re: I cant pass %devicename% as a parameter

 
SOLVED
Go to solution
Sean Wheeler
Advisor

I cant pass %devicename% as a parameter

I'm using HP SIM 5. I'm trying to output all my events to text files. I have a vbscript which writes all the parameters passed to it to a text file.

When I pass the parameters
"plain %noticeplaintext% name"
it works as expected.

However when I try and pass the parameters
"plain %noticeplaintext% name %devicename%"
I get the following error

"One of the tool's parameterized strings failed to expand. Invalid "% " token found in the parameterized string at column 22."

Does anyone have an example of passing serveral HP SIM parameters? Or can people spot an obvious syntax error I am making? I have tried other parameters and noticeplaintext is the only one that has not given me an error.

Any help would be appreciated!

Cheers
8 REPLIES 8
Rob Buxton
Honored Contributor

Re: I cant pass %devicename% as a parameter

I see there are no responses, so apologies in advance I've no vb experience.

Are you just picking up the parameters HPSIM passes by default?
I use perl, and to ensure the standard environment variables passed are picked up I use the "use env;" construct.

From there I can access any of the standard variables passed by HPSIM including DEVICENAME and others.
In perl they're just preceded by a "$" and by convention are capitalized.

Just to clarrify, I do not populate any environment variables in the Custom Command set up. I just use those passed by default.
Sean Wheeler
Advisor

Re: I cant pass %devicename% as a parameter

I'm sorry I didnt explain my question very clearly. I have tested my VBscript and it works as I intended - I only mentioned it to help provide a background to my problem.

I am trying to pass the device name of the machine that caused an event to my script as a parameter. However when I write %devicename% in the parameters text box, the SIM console gives me the invalid token error I mentioned in my first post. From the HP SIM documentation I believe %devicename% is one of the parameters HP SIM can pass.

I don't utilise any environment variables in the Custom Command set up either.
Sean Wheeler
Advisor

Re: I cant pass %devicename% as a parameter

I have enclosed a screen shot of the custom command I am writing, and the error I receive when I attempt to run the command. I hope this clarifys my situation.
Rob Buxton
Honored Contributor

Re: I cant pass %devicename% as a parameter

The Parameters Box is for when you use something like perl.
My Executable & Pathname would be to the perl executable, the parameter would be the name of the perl script.

Again I've not used vb scripts, but you may not need anything in the parameters field.
Sean Wheeler
Advisor

Re: I cant pass %devicename% as a parameter

I can run my script without anything in the parameters field. However I want my script to record which device caused the error so I am trying to pass %devicename% as a parameter. This method works with the parameter %noticeplaintext%.

How do you pass event data to your scripts when writing in PERL?


Rob Buxton
Honored Contributor
Solution

Re: I cant pass %devicename% as a parameter

The DEVICENAME and other parameters are passed by default by HPSIM, you just need to read them. I believe they're set as environment variables.

In perl you use the "use env;" construct. After that I just need to use the $DEVICENAME in the script.

So a set up like the following:
The path to executable would be - c:\perl\bin\perl.exe
The parameter would be - d:\mydirectory\test001.pl

And test001.pl would be something like:

use Env;

$Outfile = $DEVICENAME."mailfile.tmp";
open MAILTMP, ">$Outfile";

# Format the Mail Message
print MAILTMP <Fwdgroup:Server Support
Impact_ref:5
Urgency_ref:5
Configitem:$DEVICENAME
Customer:phredde@myco.nz
Problemdesc:$NOTICEPLAINTEXT
System:insight_manager

MAILEND0
close MAILTMP;

In this case I pick up and use the two variables.
Sean Wheeler
Advisor

Re: I cant pass %devicename% as a parameter

Thanks for all your help Rob, I understand now :)
Sean Wheeler
Advisor

Re: I cant pass %devicename% as a parameter

If anyone else is using VB script they may find this useful.

I've attached my simple VB script that reads all the Process environment variables and writes them out to a log file.