Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-19-2019, 04:25 AM
Allan_D Allan_D is offline
Registered User
 
Join Date: Jul 2019
Posts: 3
ScreenSend variable

Hi
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)


Code:
>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.
Reply With Quote
  #2  
Old 07-19-2019, 08:28 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,943
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 07-23-2019, 03:27 AM
Allan_D Allan_D is offline
Registered User
 
Join Date: Jul 2019
Posts: 3
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


Code:
#$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.WaitForStrings(vWaitFors)
	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)
	
	
	
	next
	
    crt.Screen.WaitForStrings(vWaitFors)
	
	
End Sub
Reply With Quote
  #4  
Old 07-23-2019, 08:53 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,943
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:
Code:
	crt.Screen.Send "dis bgp vpnv4 vpn & vLines(nIndex) & peer" & chr(13)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 07-30-2019, 05:56 AM
Allan_D Allan_D is offline
Registered User
 
Join Date: Jul 2019
Posts: 3
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.
Reply With Quote
  #6  
Old 07-30-2019, 07:56 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,943
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.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 07-30-2019 at 08:04 AM. Reason: clarification
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:37 AM.