You must be a MyPeek member to download our extensibility solutions. Click here to learn more about the benefits of membership and find out how to sign up for free.
You must have a valid maintenance contract to download this file.
If you are not a LiveAction Maintenance Customer but would like to purchase a Maintenance contract for your LiveAction product please click here for sales information.
Category : Scripts
Submitted By : Chris Bloom
Downloaded : 159 Times
Rating : Not Yet Rated
View Comments (0)
This OmniScript sample demonstrates how to define and send a new filter to an OmniEngine, and create a capture that uses it.Assumptions
- OmniScript is already installed
- script is being run from same machine as engine
- script is located at c:omniscript
Preparation
The code below depends on two extra files that are contained in the zip download. One is the filter file that is loaded into the OmniEngine. The other is the capture template file that is used to create a capture which uses the new filter.
To create a filter file, connect to an OmniEngine, go to the Filters tab, create a new filter, and export it to a file. When exporting to a file, all of the filters will be exported, so open the file and remove all of the others. You will also have to wrap the filter in an extra set of tags to for OmniScript to accept it. This is illustrated below with the extra "doc" tags which were added after the save:
Filter File
<?xml version="1.0" encoding="UTF-8"?> <doc> <filters> <filterobj clsid="{22353029-A733-4FCC-8AC0-782DA33FA464}"> <filter id="{912F9B7A-22C8-46CE-8181-17642461C519}" name=" Custom IP Filter" color="0" created="12873424979527733400" modified="12873424979527733400"> <rootnode clsid="{D2ED5346-496C-4EA0-948E-21CDDA1ED723}"> <filternode inverted="0"> <addr1 class="2" type="21" data="0A040331"/> <addr2 class="2" type="21" mask="0" data="00000000"/> <accept1to2 data="1"/> <accept2to1 data="1"/> </filternode> </rootnode> </filter> </filterobj> </filters> </doc>
The filter shown above is an address filter. If you wanted to dynamically change any part of it in your code, you could change the values to variable names like $VAR1 or something and write code to replace the vars with actual values.
Template File
The template file is rather large so we will not display it here. It is in the zip file, We will though show the piece that refers to the filter show above. As will see, the filter is specified by the GUID. I hope you like GUID's, because OmniScript uses them for everything.
... <obj name="FilterConfig" clsid="{84D2EAC7-3B74-420E-8EEE-85C7165BB471}"> <filterconfig mode="1"> <filters> <filter id="{912F9B7A-22C8-46CE-8181-17642461C519}"/> </filters> </filterconfig> </obj> ...
Code
option explicit Dim EPRCmdMgr Dim RemoteAdapterList Dim errVal Dim nAdapterCount Dim i, j, count, adapterName, captureGUID Dim captureList, captureInfo Dim EngineIP, EnginePort Dim xmlTranslate Dim xmlFilters Dim xmlTemplate Dim testFilters Dim name, comment On Error Resume Next '--------------------------------------------------- ' Create the Remote Command Manager '--------------------------------------------------- set EPRCmdMgr = CreateObject("EPRCmdAPI.WPRemoteCmdMgr") '--------------------------------------------------- ' Connect to Engine '--------------------------------------------------- EngineIP="127.0.0.1" EnginePort=6367 WScript.Echo "Connecting to Remote Agent at " & EngineIP & ":" & EnginePort errVal = EPRCmdMgr.Connect(EngineIP, EnginePort, 30000 ) if Err.number <> 0 then WScript.Echo Err.Description WScript.Quit end if if errVal <> 0 Then WScript.Echo "Connect Failed" & vbNewLine WScript.Echo "Press Enter to finish..." WScript.StdIn.ReadLine() WScript.Quit end if '--------------------------------------------------- ' Load filter file '--------------------------------------------------- set xmlTranslate = CreateObject("EPRCmdAPI.XmlTranslate") ' Load "test" filters from XML set xmlFilters = CreateObject("Microsoft.XMLDOM") xmlFilters.async = False WScript.Echo "Loading filters from file" errVal = xmlFilters.Load( "c:omniscriptfilters.flt" ) if (errVal <> True) Then WScript.Echo "Failed to load filters from file" WScript.Echo "Error:" & errVal WScript.Quit end if '--------------------------------------------------- ' Translate filter file '--------------------------------------------------- WScript.Echo "Translate filters" set testFilters = xmlTranslate.Load( xmlFilters, xmlFilters.lastChild, "PeekFilters.FilterCollection" ) if Err.number <> 0 then WScript.Echo Err.Description WScript.Quit end if '--------------------------------------------------- ' Send filter file '--------------------------------------------------- WScript.Echo "Sending filters to engine" errVal = EPRCmdMgr.SetFilters( testFilters, 1 ) if Err.number <> 0 then WScript.Echo Err.Description WScript.Quit end if '--------------------------------------------------- ' Load capture template file '--------------------------------------------------- set xmlTemplate = CreateObject("Microsoft.XMLDOM") WScript.Echo "Loading template from file" errVal = xmlTemplate.Load( "c:omniscriptcapturetemplate.xml" ) if (errVal <> True) Then WScript.Echo "Failed to load template from file" WScript.Echo "Error:" & errVal WScript.Quit end if '--------------------------------------------------- ' Create a capture '--------------------------------------------------- WScript.Echo "Creating new capture" captureGUID = EPRCmdMgr.CreateNewCaptureFromTemplate( xmlTemplate ) WScript.Echo "Capture Created GUID: " & captureGUID if err.number <> 0 Then WScript.Echo "Failed to create new capture" & vbNewLine &_ "Error Code: " & err.Description WScript.Quit End IF '--------------------------------------------------- ' Start Capture '--------------------------------------------------- EPRCmdMgr.StartCapture(captureGUID) WScript.Echo "Done" WScript.Quit