Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting


Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-28-2019, 07:43 PM
MattP MattP is offline
Registered User
Join Date: Jun 2019
Posts: 2
Python - ReadString Issues using Array

Hello Everyone,

I have been scripting via SecureCRT for a while, but I've run into an issue that I believe may be a bug.
I was trying to rework my 'SendAndReturn', which just sends a command and returns a two dimensional array. Currently the problem is that on commands with extremely long outputs (i.e. ARP cache on a router that feeds ~15000 cable modems) the ReadString function locks up pretty aggressively for 10/15 minutes.

My work around for this was to process the data one line at a time, then append it into a text variable. This was able to accomplish what I need, it runs through the command properly without stalling, however it doesn't appear that the list function on ReadString is working appropriately. When I debugged, it seemed that it was processing the \r\n properly but not the #.
I attempted to replace it with the full name of the chassis to see what out happen, and it still didn't catch. When I hit 'enter' it detected the CR and saw the #, so it gave me the dialog box, but it removed the name of the chassis from the output. I.E.
became simply "#" on that line in the dialog output.

When I run it exactly as below, it will not even end when I hit Enter and generate a new \r\n and feed it a line containing the "#", it does not find it - i believe because it's removing the # from the string, so it is unable to find it.
I'm hoping that someone can give me some input on this. I'm currently on 8.1.0 x64 build 1294. If there is a newer version I won't be able to update due to my organizations IT policies - until they do they entire organization, so I'm hoping to find a work-around regardless. Any help would be greatly appreciated!

def Main():
TESTOUTPUT = SendAndReturnLONG("show int l0")

SESSIONID = crt.GetScriptTab()
SESSIONID.Screen.Synchronous = True
SESSIONID.Screen.IgnoreEscape = True
Response = ""
LoopBreak = 0
while LoopBreak == 0:
Response = SESSIONID.Screen.ReadString(["\r\n","#"])
#crt.Dialog.MessageBox("hit a CR")
if OUTPUTSTRING[-1:] == "#":
LoopBreak = 1
Response = None
Reply With Quote

array , python , readstring , scripting

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 06:51 AM.