473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Perl script to look only for the desired keyword on cisco router

Hi Guys,

I'm new to Perl and to this forum and I hope you gurus here help me.

I am building a perl script that will telnet to one of my cisco router and execute commands. I was able to do this task using perl module Net::Telnet::Cisco and able to execute router commands successfully.

I want is for example. from cisco "show version" commands, I only want to appear only the

myrouter uptime is 16 weeks, 3 days, 23 hours, 50 minutes
System returned to ROM by bus error at PC 0x60279CDC, address 0x0 at 16:52:00 Fri Jul 20 2007
System restarted at 16:52:14 Fri Jul 20 2007
System image file is "flash:c5350-js-mz.123-1.bin

I only want to appear only that line and omit other lines that are irrevelant.

b. another example is like I only want to know the CRC errors, or if the interface is UP or down when i execute the "show interfaces" command.

To sum up, I only want to display by executing the commands the lines or keywords that I want

Hope you can help me on this.thanks in advance
Sep 5 '07 #1
3 5978
KevinADC
4,059 Expert 2GB
I am totally unfamiliar with cisco router commands. Do the commands display more lines that you want? Is that normal? What does get displayed?
Sep 5 '07 #2
I'll cite an example, my perl script will execute this router commands

myrouter#show health-monitor
Chassis:
Power Supply OK
Redundant Power System is present.
PS Input Voltage status: normal
PS Output Voltage status: normal
PS Fan status: normal
PS Thermal status: normal
PS OverVoltage status: normal
Temperature OK
Fans OK

Memory:
Free Memory processor OK
Memory Fragmentation Processor OK
Free Memory I/O OK
Memory Fragmentation I/O OK
Memory summary:

it will display several lines,let say I only want to display this 3 lines just to summarize

Power Supply OK
Temperature OK
Fans OK

and omit the other lines that are not so relevant


do i use cut, awk grep command?
Sep 6 '07 #3
KevinADC
4,059 Expert 2GB
Net::Telnet::Cisco is a subclass of Net::Telnet which allows you to define search patterns. I am pretty sure its the "waitfor" option. See Net::Telnet for details about defning search patterns:

cpan: Net::Telnet
Sep 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts...
2
by: Kai Thorsrud | last post by:
Hi I'm currently into converting a perl linux app into a .Net windows service. The application monitors our syslog log files to capture i.p adress changes on some of our routers having dynamic...
2
by: perlandtcl | last post by:
Can any one suggest any link for perl expect.... and few examples for automation of router and switch configurations .. apart from the tcl feature available in CISCO IOS
20
by: Shawn Milo | last post by:
I'm new to Python and fairly experienced in Perl, although that experience is limited to the things I use daily. I wrote the same script in both Perl and Python, and the output is identical. The...
1
by: Balajisanthanakrishnan | last post by:
Old Title: Hi all, need help for this perl script- thanks in advance I am BalajiSanthanakrishnan, chennai. Now I am working in a Perl Script which is executing in the Unix Servers. Basically i am...
1
by: wcl152010 | last post by:
Hi, I have a general doubt here regarding of monitoring different model of CISCO Switches and Routers. I am new in SNMP, I tried to search for CISCO related mib file in the net and i got at...
3
by: Shahjehan | last post by:
I have to configure Cisco Router and get their sh-run on my PC using python. Is this possible? Do cisco routers provide provision of accessing them through scripting?
3
by: Friedman, Jason | last post by:
I have lines that look like this: select column1, 'select' as type from table where column2 = 'foo' I want to return: SELECT column1, 'select' AS type FROM table WHERE column2 = 'foo'
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.