VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Grabbing a long list of data output from screen (https://forums.vandyke.com/showthread.php?t=12379)

yuvi 06-08-2016 01:22 AM

Grabbing a long list of data output from screen
 
Hi guys,

So am trying to grab a whole lot of output of a command from the command line.

I am using crt.screen.send to punch the command on to the CLI and using a temporary text file to read each line.

Here is what am doing,

Quote:


crt.screen.send "show port " & vPort &vbcrlf &vbcrlf

crt.screen.send vbcrlf

crt.Screen.WaitForString vbcrlf, 10

crt.screen.send "#" &vbcrlf




crt.Screen.WaitForString vbcr, 10

vPortFetchLine = crt.Screen.ReadString("#")

Then I am using a writeobj to write it on to a temporary text file and then read the same from it.

The problem with this is that I can't read the lines after certain lines which in real time would require me to hit a spacebar. I am using vbcrlf to display all the output on the screen but am only able to grab the lines or output before I am giving the command "vbcrlf"


for instance if have several lines as output,

line1
line2
.
.
.
.
line30
Press any key to continue (Q to quit)
This is where I am required to hit spacebar in real time when working with script.

I gave several vbcrlf to overcome the challenge of hitting spacebar in the script.

What am unable to do though is not able to grab the entire output all am getting is till Press any key to continue (Q to quit), although I can literally see the rest of the output being displayed on the screen.

So it should be something like this (assuming am getting 60 lines on the screen),

Quote:


line1
line2
.
.
.
.
line60

Instead all am getting in my textfile is,

Quote:


line1
line2
.
.
.
.
line30
Press any key to continue (Q to quit)

I may sound crazy, I hope I conveyed my point. Please correct my mistake and help me read all the output of this particular command.

Thanks in advance!

Yuvi

rtb 06-08-2016 10:04 AM

Hi Yuvi,

Thanks for the post.

An example of how one could accomplish your goal is included in the scripting manual at the following location:
https://www.vandyke.com/support/tips...ing/index.html
The example begins on page 50 with the heading of: Using MatchIndex to Determine Which String ReadString() Detected.

Does this help you accomplish your goal?

yuvi 06-08-2016 05:46 PM

Thanks for the reply rtb!

I tried that already, gave it another go, still I am unable to read all the data output of my command "show port"

All this does is matching the index to the string where you need a space, gives a space and displays the whole data on to the screen.

But, still unable to read the whole data.

Here is what I did, (FYI, I am not working with CISCO, its Bastian, if that helps

Quote:


crt.Screen.Synchronous = True

crt.screen.send "show port " & vport & vbcr

crt.Screen.WaitForString vbcr

strCompleteOutput = ""

Do


strResult = crt.Screen.ReadString("* indicates that the corresponding row element may have been truncated.", "Symbol Errors")



strCompleteOutput = strCompleteOutput & strResult

If crt.Screen.MatchIndex = 1 Then crt.Screen.Send " "

If crt.Screen.MatchIndex = 2 Then Exit Do
Loop

strCompleteOutput = Replace(strCompleteOutput, _
vblf & vbcr & vbcr & " " & vbcr, vblf & vbcr)

MsgBox strCompleteOutput


Still it just reads the output till before "* indicates that the corresponding row element may have been truncated"

I want he output till "symbol Errors"

which is not happening.

rtb 06-09-2016 10:09 AM

Hi Yuvi,

What version of SecureCRT are you using?

I don't have any familiarity with Bastian.

Would you be able to post the output of the command?
NOTICE: The requested troubleshooting data may include sensitive information (usernames, passwords, publicly-accessible host names or IP addresses, etc.).

Please redact sensitive information that would not be appropriate for a public forum prior to posting the requested information.

If there is sensitive information that must be conveyed in order to provide a complete picture of the scenario you're facing, please let us know and we will set up a secure upload mechanism that can be used.

Rhudi 07-08-2016 07:03 AM

In Cisco devices, "terminal length 0" stops the 'more' prompt.

Juniper: "set cli screen-length 0"

Most router have a similar option.


All times are GMT -6. The time now is 12:08 PM.