Hey bgagnon,
Yep, you were correct.. I had a logic failure around including the # in the captured text. Thanks for your help with that! Last week was a very long week, haha.
Here is the code working to pull back the string, for anyone who may be interested, corrected for this logic.
This runs much faster than trying to use just ReadString("#") to capture very long output to a string.
Code:
def Main():
TESTOUTPUT = SendAndReturnLONG("show int l0")
crt.Dialog.MessageBox(TESTOUTPUT)
def SendAndReturnLONG(COMMANDTEXT,SESSIONID="DEFAULT"):
if SESSIONID=="DEFAULT":
SESSIONID = crt.GetScriptTab()
SESSIONID.Screen.Synchronous = True
SESSIONID.Screen.IgnoreEscape = True
SESSIONID.Activate
SESSIONID.Screen.Send(COMMANDTEXT + "\n")
OUTPUTSTRING = ""
Response = ""
while 1:
Response = SESSIONID.Screen.ReadString([COMMANDTEXT + "\r\n","\r\n","CHNDCAPC02"])
if SESSIONID.Screen.MatchIndex == 1:
pass #I don't want the first line of output with the command I issued, so pass
elif SESSIONID.Screen.MatchIndex == 2:
OUTPUTSTRING = OUTPUTSTRING+"\r\n"+Response #Append the current line to the total output, re-adding the CR
elif SESSIONID.Screen.MatchIndex == 3:
break #end the loop. I also don't want the last line with the TID of the chassis, so don't add it.
Response = None
SESSIONID = None
return OUTPUTSTRING
OUTPUTSTRING = None
Main()