Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 02-08-2012, 07:04 AM
Wim_DP Wim_DP is offline
Registered User
 
Join Date: Mar 2008
Posts: 37
Capturing output of multiple lines

Hi,

We would like to capture the output of a command on a Cisco router and place it in a messagebox.
The command is used to check how many events have been triggered the last week.
The difficulity lies in the fact the number of lines can vary between none and max 50 ( max number of events in the memory of the router.

I would like that the scripts capture everything between the command ( show event manager ...) and when he returns to his default prompt (#)
This output must then be showed in a messagebox

Is this possible ?

Arg-gebouw-84-R01#sho event manager history eve | incl Explore
Actv success Fri Feb 3 08:58:38 2012 track applet: Explore_UP
Actv success Wed Feb 8 12:34:11 2012 track applet: Explore_DOWN
Actv success Wed Feb 8 12:37:26 2012 track applet: Explore_UP
Arg-gebouw-84-R01#


Thx
Wim
Reply With Quote
  #2  
Old 02-08-2012, 09:22 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Wim,

What you have described should be possible.

Are you having trouble accomplishing this goal with a script you have created?

If so would you post the script you are trying to use?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 02-08-2012, 12:16 PM
Wim_DP Wim_DP is offline
Registered User
 
Join Date: Mar 2008
Posts: 37
Hi Todd,

I 'm not so good in scripting , I found one script in the scripting forum using an array but I couldn't get this working.
Another script was in the scripting essentials manual but the problem with these commands was , in my humble opinion, that I went back for a fixed number of lines . Since the number of lines is varying in my command output I don't think this is a solution.

Rgds

Wim
Reply With Quote
  #4  
Old 02-08-2012, 04:12 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Wim,

It seems like you should be able accomplish your goal using a few methods from the Screen object.

You could use the Send() method to send your command. You could then use the WaitForString() method to wait for the command including the carriage return. You could finally use the ReadString() method to get the data from the point when the device prompt is found to the beginning of the output after the command was found by WaitForString().

These methods are all documented in Help. The chapter would be Scripting / Script Objects Reference / Screen Object. The use of these methods is also discussed in the forums and chapters 4 and 5 in the scripting manual in detail.

Does this help you get started writing your script?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 02-09-2012, 12:27 AM
Wim_DP Wim_DP is offline
Registered User
 
Join Date: Mar 2008
Posts: 37
Hi Todd,

I tested it with the readstring command and this is what I need. Unfortunately my msgbox is not big enough. How can I resize this ?
Is it possible to resize a msgbox dynamically ?

gr
Wim
Reply With Quote
  #6  
Old 02-09-2012, 08:00 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Wim,

A message box cannot be resized to my knowledge. Are the lines to long and end up getting wrapped?

If so, have you tried formatting the text rather than just displaying it?

In your first post, the example output is only about 275 characters. A message box should be able to display about 1024 characters.

Is the text just too much to fit in a message box?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #7  
Old 02-09-2012, 08:14 AM
Wim_DP Wim_DP is offline
Registered User
 
Join Date: Mar 2008
Posts: 37
Hi,

It is not only this capture that will come into the msgbox but also other output of various show commands.
Most likely this will oversubscribe the limit of 1024 characters :-(

Is there an alternative ?

gr

Wim
Reply With Quote
  #8  
Old 02-09-2012, 08:32 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Wim,

To suggest alternatives, it would be helpful to know what your goal is.

Are you going to be using the message boxes permanently to display the data to the end user or is this a debugging mechanism that you are going to be using temporarily?

If this is a permanent solution, can you tell me more about your overall goal?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #9  
Old 02-09-2012, 08:46 AM
Wim_DP Wim_DP is offline
Registered User
 
Join Date: Mar 2008
Posts: 37
Hi Todd,

The goal is that our helpdesk sees the output of specific commands. This has the advantage that they don't need to login to the routers and do the analysis.

I just need a popup which gives me the output and what they could copy out of the output to an helpdesk ticket

So yes the solution is for a permanent base

thx
Wim
Reply With Quote
  #10  
Old 02-09-2012, 09:14 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Wim,

Now that I know more about your goal, here are the suggestions I have in order of what I think would be easiest/most effective to hardest/least effective.

Use the Clipboard:
It seems like you might be able to accomplish your goal by adding the data to the clipboard, and then telling the user via a message box that they can just paste the data into the helpdesk ticket. An example using the clipboard to do this is illustrated in chapter 8.2 of the scripting manual.

Write the data to a file and open it:
Another option might be to write the data to a file, and then open that file for the user. Chapter 7.3 in the scripting manual discusses writing data to files. After the data is written to the file, you could use a message box to tell the user that you are going to open the file in Notepad, or you could use a message box to inform the user that the data is written to a file, provide the filename and then use the FileOpenDialog() method of the Dialog object to allow the user to select the file an manually open it.

Use custom HTML webpage:
Another option you might want to investigate using would be to display the data in a webpage. Something similar is included in chapter 6.3 of the scripting manual.

Does this information help you accomplish your goal?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #11  
Old 02-13-2012, 07:56 AM
WesR WesR is offline
Registered User
 
Join Date: Mar 2005
Location: USA
Posts: 149
Also, in case this was missed, be sure you are using the SecureCRT message box as apposed to the VB msgbox. I.E use:

crt.Dialog.MessageBox

not

msgbox

The SecureCRT Message box allows a lot more information to be displayed.

Wes
Reply With Quote
Reply

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 10:26 PM.