Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

long constants put back together! 1

Status
Not open for further replies.

miteshlad2

Technical User
Feb 20, 2007
4
GB
Hello all,

I've put together the following script which should fire the following snmp trap through a DOS Window when a certain process is detected, in this case i have used notepad.exe:

awtrap -f swccasn2 -h 10.101.44.31 -p 162 -c public 1 6 12 1 -s "hello this is a test trap"

however as the trap is rather big i have broken it down into many contants (hope there is an easier way to do this)

Question I have is how do I put the constants together again???

Here's what i've done so far...

Thanks

Mitesh
-----------------

Const TRAP1 = "awtrap"
Const TRAP2 = "-f"
Const TRAP3 = "LONW00054218"
Const TRAP4 = "-h"
Const TRAP5 = "10.101.44.37"
Const TRAP6 = "-p"
Const TRAP7 = "162"
Const TRAP8 = "-c"
Const TRAP9 = "public"
Const TRAP10 = "1"
Const TRAP11 = "6"
Const TRAP12 = "12"
Const TRAP13 = "1"
Const TRAP14 = "-s"
Const TRAP15 = "cars importer process has started"



strComputer = "LONW00054218"
Set objSWbemServices = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!" &_
"\\" & strComputer & "\root\cimv2")

Set objEventSource = objSWbemServices.ExecNotificationQuery( _
"SELECT * FROM __InstanceCreationEvent " &_
"WITHIN 10 " &_
"WHERE TargetInstance " &_
"ISA 'Win32_Process' " &_
"AND TargetInstance.Name = 'notepad.exe'")

Set objEventObject = objEventSource.NextEvent()
Wscript.Echo "An instance of notepad.exe just started.
 
To put them together you could do something like this.

TRAP1 & " " & TRAP2

you can see it by trying

WScript.Echo TRAP1 & " " & TRAP2

My question is why are you breaking it up in this manner?

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
I broke it up as I tried it as a whole string at first

e.g.

Const Trap = "awtrap -f swccasn2 -h 10.101.44.31 -p 162 -c public 1 6 12 1 -s "hello this is a test trap""

but this failed, I would like to have it on one line but i don't think its possible

Thanks

Mitesh
 
Const Trap = "awtrap -f swccasn2 -h 10.101.44.31 -p 162 -c public 1 6 12 1 -s [!]"[/!]"hello this is a test trap""

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Just cust and pasted your reply, but its giving me the same error message I had from the beggining..

thanks
 
Sorry for the typo.
Const Trap = "awtrap -f swccasn2 -h 10.101.44.31 -p 162 -c public 1 6 12 1 -s ""hello this is a test trap"""

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top