Named argument not found when using Virtual column
7 posts · Closed
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") 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.
Thanks Andrew, I will try to accomplish the goal without using the VC.
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?
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.
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?
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