Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-16-2017, 11:15 PM
MADperl MADperl is offline
Registered User
 
Join Date: Dec 2017
Posts: 2
SecureCRT, screen display only 'pattern' matches?

I can use Perl to spawn a router session, select only the pattern matched lines I want to display on my terminal.

Is it possible to have that same control when using my BUTTON assigned scripts.

Directly below, is an example of a BUTTON assigned script that will issue a command to the router, then display all the lines received.

At the end of this post is an example Perl Script that will only show me the pattern matched lines I am interested in. Since I can't get that to work in SecureCRT, that Perl example is reading a log file.

Can secureCRT moderate the output to the screen?

=====================================================
SecureCRT: BUTTON assigned script
=====================================================
# $language = "PerlScript"
# $interface = "1.0"

$true = 1;
$false = 0;

$vlan = $crt->Dialog->Prompt("Enter your VLAN ID: ", "vlanid", "", $true);

$crt->Screen->{'Synchronous'} = $true;
$crt->Screen->Send("show router interface to-7705-$vlan detail\015");
$crt->Screen->Send("q");
=====================================================
=====================================================
Perl Script: Only displays lines that match a PATTERN
=====================================================
my $filename = 'C:\tmp\LogFile.txt';
open(my $fh, '<:encoding(UTF-8)', $filename)
or die "Could not open file '$filename' $!";
while (my $row = <$fh>) {
chomp $row;
my $string = $row;

if (defined($string) && ($string =~ m/# show router interface/)) {
print "$row\n"; }
elsif (defined($string) && ($string =~ m/Admin State :/)) {
print "$row\n"; }
elsif (defined($string) && ($string =~ m/Description :/)) {
print "$row\n"; }
elsif (defined($string) && ($string =~ m/Port Id :/)) {
print "$row\n"; }
elsif (defined($string) && ($string =~ m/MAC Address :/)) {
print "$row\n"; }
}
close $fh;
=====================================================
***** O U T P U T *****

*A:AAABBB00# show router interface "to-7705-2300" detail
Admin State: Up Oper (v4/v6) : Up/Down
Description: XX12345X
Port Id : 1/2/15:2300
MAC Address: a4:7b:2c:05:c9:b3 Mac Accounting : Disabled
=====================================================
Reply With Quote
  #2  
Old 12-18-2017, 09:28 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi MADperl,

SecureCRT will always display all the text sent by the remote system. That being said you may be able to get behavior similar to what you're looking for using SecureCRT's Keyword Highlighting feature.

Keyword Highlighting allows you to use color for aiding in your pattern-matching where you need to spot things that are "important". For example: Want the word "Error" to always appear on the screen in red? Or how about "Failed" or "down", etc? This is where keyword highlighting can help... and with support for regular expression highlighting (Windows only for the time being), words can be highlighted by specifying a pattern -- so you can color IP addresses for easy detection, as one example. Here's a pretty good discussion on it, with some screen shots from forum community member, Casey: https://forums.vandyke.com/showpost....95&postcount=1

Keyword highlighting does not currently support highlighting multi word patterns. I've added you to feature requests for both multi word and full line highlighting. Should these options become available we'll be sure to post here.

Does this help get you the functionality you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 12-19-2017, 04:17 AM
GJB56 GJB56 is offline
Registered User
 
Join Date: Nov 2011
Posts: 22
I also would find multi word high lightning very useful
Reply With Quote
  #4  
Old 12-19-2017, 07:49 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,207
Hi GJB56,

I have added this thread to a feature request in our product enhancement database to support substring and phrase matches in keyword highlighting (regex with spaces). Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #12946" in the subject line or use this form from the support page of our website.

See this post for the latest info.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 12-19-2017, 11:19 PM
MADperl MADperl is offline
Registered User
 
Join Date: Dec 2017
Posts: 2
I can work with that!

Highlighting a word, multi-word or the entire line will work fine for troubleshooting configurations aided by button defined scripts.

For report style queries from multiple MAD routers (i.e., gathering total LDP sessions, interfaces that are Up or Down, ... etc ...)

I guess I have 2 directions try. . .

Using SecureCRT
==================
...Open a logfile to append query results to.
...Launch SecureCRT using saved sessions and a query script.
It might be problematic having the screen continuously scrolling on a laptop that is also multitasking with other work.


Using Perl with Net SSH
=======================
...Open a logfile
...Open a MAD_List file, w/host names for routers to be queried.
...Spawn router sessions, login and issue command
1st attempt at this Perl script, has a problem. Only 1 command seems to be issued and captured per login. Whatever I am doing wrong, I haven't figured it out yet.


THANK YOU VERY MUCH !!
What you have suggested will make it much easier to view relevant data "within SecureCRT" while troubleshooting configurations.

I am open to hear anyone's thoughts for improving the logic/methods for the report style processing of data from multiple MAD routers.
Reply With Quote
  #6  
Old 12-20-2017, 08:40 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi MADperl,

If you are wanting to connect to a defined list of devices and run the same set of commands on each, capturing the output to a log file, we have an example script available that does just that. Although it's not Perl it may still be of use to you.

The example script can be found here.

Does this help get you the functionality you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 12-17-2019, 06:04 PM
Maureen's Avatar
Maureen Maureen is offline
VanDyke Product Director
 
Join Date: Feb 2004
Location: Albuquerque, NM
Posts: 1,567
The ability to use spaces in keywords (including regular expressions) has been added to SecureCRT 8.7, which is currently in beta testing. It can be downloaded here:

https://www.vandyke.com/cgi-bin/rele...curecrt&beta=1

Maureen
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 05:47 PM.