VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   ScreenSend variable (

Allan_D 07-19-2019 04:25 AM

ScreenSend variable
Having some issues sending a variable in a Screen Send.
For context.
This is on a H3c router. I first list routing instances, use Get2() to capture them to an array , then go via the array , list the peer IP , grab the peer with Get().

Then I try to list routes received from the peer but the variable do not print , i just get basic text in the screen send output:
(vLines and vPeer are the variables in this case)

crt.Screen.Send "dis bgp vpnv4 vpn" & vLines & "routing-table peer" & vPeer & "received-routes " & chr(13)


>dis bgp vpnv4 vpn & strLines(nIndex) & peer
 % Unrecognized command found at '^' position.

Sorry if this is a stupid newbie question. I read the guide and the syntax seems to be correct.

bgagnon 07-19-2019 08:28 AM

Hi Allan_D,

I'll probably need more info, such as a copy of the entire script, but one discrepancy I noticed is the first Send() in your post is showing *vLines* variable and the one wrapped in the code tags indicates *strLines(nIndex)*.

What is the corresponding code that puts info into vLines/strLines and which should it be? And does it need an index? (Is the source an array?)

That's where I suggest you start as far as debugging the script code. :)

Allan_D 07-23-2019 03:27 AM

Here is the script

The idea is i display routing instances , then using Get2() i copy the first column to an array.
Then i use a for loop. I list BGP peers for each routing instance and using Get() i grab the IP.
Then using the routing instance and peer IP i list routes sent/received.

The reason the strlines/vlines looks a mess is i tried to adapt the example from your guide to scripting , chapter 4.3


#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

Dim vWaitFors
'define array to contain ex instances - make it no larger than 150 , we dont expect more
'Dim strLines(150)
Dim vPeer

vWaitFors = Array("<redacted device name1><redacted device name2>")

' This script is very amateurish

Sub Main
        crt.Screen.Send "screen-length disable" & chr(13)
        crt.Screen.Send "dis ip vpn | i ex" & chr(13)
        'assume capture starts at -68 row considering banners on idajump server and prompts while logging in before running script
        strLines = crt.Screen.Get2(-68,3, crt.Screen.Rows,10)
        vLines = Split(strLines, vbcrlf)
    For nIndex = 1 To UBound(vLines)
        crt.Screen.Send "dis bgp vpnv4 vpn & strLines(nIndex) & peer" & chr(13)
        'use get command to get peer
        vPeer = crt.Screen.Get(60,3,60,17)
        'crt.Screen.Send "dis bgp vpnv4 vpn" & vLines & "routing-table peer" & vPeer & "received-routes " & chr(13)
        'crt.Screen.Send "dis bgp vpnv4 vpn" & vLines & "routing-table peer" & vPeer & "advertised-routes " & chr(13)
        crt.Screen.Send "dis bgp vpnv4 vpn "
        crt.Screen.Send vLines
        crt.Screen.Send " routing-table peer "
        crt.Screen.Send vPeer
        crt.Screen.Send " received-routes"
        crt.Screen.Send chr(13)
        crt.Screen.Send "dis bgp vpnv4 vpn "
        crt.Screen.Send vLines
        crt.Screen.Send " routing-table peer "
        crt.Screen.Send vPeer
        crt.Screen.Send " advertised-routes"
        crt.Screen.Send chr(13)
End Sub

bgagnon 07-23-2019 08:53 AM

Hi Allan_D,

Thanks for providing some context.

It's vLines that is the array, strLines was the variable before Split(). So when using the index, the variable is vLines:

        crt.Screen.Send "dis bgp vpnv4 vpn & vLines(nIndex) & peer" & chr(13)

Allan_D 07-30-2019 05:56 AM

Thank you.
I was referencing the wrong variable.

My new issue is the start of the output as it stretches multiple screens.I try to reference -68 which i assume is correct when i run the output but it seems misaligned for Get2() as it grabs wrong output.

bgagnon 07-30-2019 07:56 AM

Hi Allan_D,

I don't know what you mean by -68. The first argument for Get2() is the starting row. In other words, row 1 is the first row of the terminal screen area. Are you trying to get data that is in the scrollback buffer?

It may be better if you just capture all the data and then parse out what you need, but I would need some sample output to know if there is a better way. :)

All times are GMT -6. The time now is 04:15 AM.