Virtual columns and Remote scripting

Started by rmpf2

rmpf2

Virtual columns and Remote scripting   15 January 2019, 01:35

Hi,
I'm trying to find out if I'm doing something wrong. This is a Virtual column that after some Regex displays a switch IP:
[VC - XML - Cisco IP Phone CDP Neighbor IP Address]

'Retrieve system info via Telnet
'This example code can be adapted to work with any device that supports the protocol

'Set credentials
user = "usera"
pass = "passworda"

'Create internal Telnet object
set objTelnet = Internal.CreateObject("Telnet")

'Set host name and port
objTelnet.Host = Input.Column("VC - XML - Cisco IP Phone CDP Neighbor IP Address")
objTelnet.Port = 23

'Make connection
objTelnet.Connect

'Wait for login prompt
objTelnet.WaitFor("Username:")
'Then send login name
objTelnet.Send(user & vbCrLf)

'Wait for password prompt
objTelnet.WaitFor("Password:")
'Then send password
objTelnet.Send(pass & vbCrLf)

'Wait for shell prompt
objTelnet.WaitFor("#")
'Then send command
objTelnet.Send("show interface trunk" & vbCrLf)

'Wait for shell prompt (when command finishes)
trunk_data = objTelnet.Recv("#")

'Return trunk_data
Output.Write trunk_data

objTelnet.Send("show mac address-table | exclude Gi1/0/49|Gi1/0/50|1/0/51|1/0/52" & vbCrLf)

'Wait for shell prompt (when command finishes)
data = objTelnet.Recv("#")

'Return data and disconnect
Output.Write data
objTelnet.Disconnect

This is the result output:
Named argument not found: 'Input.Column'

I also tried
objTelnet.Host = Input.Column("vc - xml - cisco ip phone cdp neighbor ip address")
SoftPerfect Support forum - Andrew avatar image

Re: Virtual columns and Remote scripting   15 January 2019, 09:07

I am afraid in the current implementation Virtual Columns can't be used in Remote Scripting.

Since Virtual Columns depend on data in other columns, they are calculated after all other columns, including Remote Scripting. Otherwise it could create interdependencies that can't be resolved, i.e. a Virtual Column refers to a Remote Scripting column and vice versa.
rmpf2

Re: Virtual columns and Remote scripting   15 January 2019, 10:15

Thanks Andrew, I will try to accomplish the goal without using the VC.
rmpf2

Re: Virtual columns and Remote scripting   15 January 2019, 10:22

In this case I'm trying to get values from two different Cisco IP phones models. This mean that the remote XML have two look in two different HTTP paths to later merge the result on the VC. Do you think it is be possible to add the option to look for more than one path?
SoftPerfect Support forum - Andrew avatar image

Re: Virtual columns and Remote scripting   15 January 2019, 11:09

Perhaps you could solely use Remote Scripting to run something like this?

Set doc = CreateObject("MSXML2.DOMDocument")
doc.async = false
doc.load "http:// your-url-to-XML-here"

If doc.parseError <> 0 Then
  Output.Write doc.parseError.reason
Else
Set nodes = doc.selectNodes("/root/some/expression")

For Each node In nodes
  Output.Write "Select output: " & node.text
Next
End If

It basically pulls an XML document and selects one or more nodes from it. Implementing conditional branching should be easy, e.g. you can try several HTTP paths and then post-process the result as you see fit.

By the way, regular expressions are available in VBScript - here is an overview of how to use VBScript Regular Expressions.
rmpf2

Re: Virtual columns and Remote scripting   17 January 2019, 07:32

Hi Andrew.
Do you mean that it can be possible to achieve the same results obtained from remote xml feature with your post recommendation of Remote Scripting - "MSXML2.DOMDocument"?

If possible, can you give an example? Perhaps one that's already included on the built-in set. Maybe the sample of PowerLogic EGX 100 S/N?
SoftPerfect Support forum - Andrew avatar image

Re: Virtual columns and Remote scripting   18 January 2019, 15:54

When I suggested MSXML2.DOMDocument I wasn't sure whether you are dealing with with a XML or HTML response. It's really only suitable for XML, but HTML can be retrieved with MSXML2.XMLHTTP instead and parsed with VBScript's regex engine.

This example equivalent to the sample PowerLogic EGX 100 S/N. It basically gets HTML from the specified URL and applies the same regex to extract the data.
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")

oXMLHTTP.Open "GET", "http" & ":// " & Input.Current & ":8001/diagnostics.shtml", False, "username", "password"
oXMLHTTP.Send

If oXMLHTTP.Status = 200 Then

  'Setup a regex object
  Set objRegex = New RegExp
  objRegex.IgnoreCase = True
  objRegex.Multiline = True
  objRegex.Global = True
  objRegex.Pattern = "Serial Number:[^>]*</td>\s*<td[^>]*>(\w*)</td>"

  Set matches = objRegex.Execute(oXMLHTTP.responseText)
  For Each match in matches
    Output.Write match.SubMatches(0)
  Next
End If

Reply to this topic

Sometimes you can get the answer faster if you try the forum search and/or have a look at the software user manual to see if your question has already been answered.

Our forum rules are simple:

  • Be polite.
  • Do not spam.
  • If possible, check your spelling and grammar.

Author:

Email:

Subject

A brief and informative title for your message, approximately 4–8 words:

     

Spam prevention: please enter the following code in the input field below.

 ********  ********   *******   **    **  **     ** 
 **        **        **     **   **  **   ***   *** 
 **        **        **           ****    **** **** 
 ******    ******    ********      **     ** *** ** 
 **        **        **     **     **     **     ** 
 **        **        **     **     **     **     ** 
 ********  ********   *******      **     **     ** 

Message: