473,657 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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::Ci sco 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:c535 0-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 5991
KevinADC
4,059 Recognized Expert Specialist
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
bossingdarwin
2 New Member
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 Recognized Expert Specialist
Net::Telnet::Ci sco 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
3028
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 for study. For below statements I couldn't understand what is the function of '$in'. I tried to search through the perl script tutorial pages since this morning (now it's afternoon) but still couldn't find the explanation. Could anyone help...
2
7005
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 i.p. In the syslog logfile i capture the new IP adress of the router. I then need to telnet to that i.p adress and fetch the hostname. A list of these routers will be presented on a webpage. I've created the application in vb.net and most parts...
2
15229
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
2206
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 run speed is similar (very fast) and the line count is similar. Now that they're both working, I was looking at the code and wondering what Perl-specific and Python-specific improvements to the code would look like, as judged by others more...
1
1633
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 Oracle plsql programmer, but i need to work nowadays in Perl also. In my perl script, there are some entries like $oid_to_get='1.3.6.1.2.1.4.22.1.2'; $comm = bones; $comm2 = public; $port = 161; $done{$router} = "skip";
1
2283
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 least 600++ CISCO mibs available now. So I am wondering 1) Which mib file is actually suitable for me? 2) Is there any particular mib file for different CISCO model? 3) Let's say I have 7206VXR router and WS-C2950G-24-EI switch, so how can I...
3
4330
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
1474
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
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.