Python - ReadString Issues using Array
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!
TESTOUTPUT = SendAndReturnLONG("show int l0")
SESSIONID = crt.GetScriptTab()
SESSIONID.Screen.Synchronous = True
SESSIONID.Screen.IgnoreEscape = True
SESSIONID.Screen.Send(COMMANDTEXT + "\n")
OUTPUTSTRING = ""
Response = ""
LoopBreak = 0
while LoopBreak == 0:
Response = SESSIONID.Screen.ReadString(["\r\n","#"])
#crt.Dialog.MessageBox("hit a CR")
OUTPUTSTRING = OUTPUTSTRING+"\r\n"+Response
if OUTPUTSTRING[-1:] == "#":
LoopBreak = 1
Response = None
SESSIONID = None
|array , python , readstring , scripting|
|Display Modes||Rate This Thread|