Expect script to show cisco configs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect script to show cisco configs
# 1  
Old 05-20-2013
Expect script to show cisco configs

I know there are better ways to do this.

I prefer snmp. I do not have the proper perl modules loaded on the platorm. Snmp isnt loaded on the platform. Telnet is not an option. I need to write an expect script to pull cisco equipment configs.

The following code is executed once I gain access.
the running config is large.


I need to capture the show run output to a file.

Code:
expect $prompt 
send "term len 0\r"
expect $prompt 
set timeout 60 
send "show running\r"
sleep 20
expect $prompt 
send "term len 25\r"
expect -re "end*\#"
send "exit\r"

any help would be greatly appreciated.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cisco, 2 ssh logins for expect /bash

HI all i need to connect to about 900 cisco routers and switch to do some configs changes. the issue i am having is that half the devices have one set of username and password and the other half have another username and password. From expect or bash script i can ssh into a device and make... (0 Replies)
Discussion started by: quintin
0 Replies

2. Shell Programming and Scripting

Can someone please show me a very simple "expect" script to change password in Solaris please?

Ladies & Gents, Can one of you gurus please show me a very simple "expect" script to change the password in Solaris in a script, please? Nothing fancy, no error checking, no nothing. Just to change the password of a new user, it's all. Many thanks in advance. U guys have honestly earned my... (1 Reply)
Discussion started by: Hiroshi
1 Replies

3. Shell Programming and Scripting

Bash script failed with expect on cisco routers

Hi all, I use a bash script which use expect to connect throught ssh and run command on a cisco router. The ssh connection with expect work fine, but the first command on the cisco router failed, I try to run the command in error by hand and it work fine... :( the first part of the script... (2 Replies)
Discussion started by: bedomon
2 Replies

4. IP Networking

How to show Cisco Router Running Configuration in Third Party Application

Hey everyone, I have a few question. 1. Is it possible to display cisco 'show run' output command to the application ?? 2. And is there any ways to log in to the router instead of using telnet from telnet application??? Thanks in advance (0 Replies)
Discussion started by: franzramadhan
0 Replies

5. Shell Programming and Scripting

Expect/telnet/testing tacacs on a cisco

At times I find the need to test that the tacacs port 49 is open. The code below works but is painfully slow because I have to wait on the timeouts. Examples of possible responds router1#telnet 10.11.20.14 49 Trying 206.112.204.140, 49 ... Open route1#telnet 10.11.19.14 49 Trying... (1 Reply)
Discussion started by: popeye
1 Replies

6. Infrastructure Monitoring

Script to sort Cisco configs

Hi everyone :), I need sort Cisco configs to report but i cannot do the script to made this: #### INPUT ##### config-register 0x2102 version 12.2 ! hostname Router ! interface Ethernet0 description Red LAN ip address 192.168.1.1 255.255.255.0 no cdp enable ! interface Serial0... (6 Replies)
Discussion started by: azrael75
6 Replies

7. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies
Login or Register to Ask a Question
Module::Loaded(3pm)					 Perl Programmers Reference Guide				       Module::Loaded(3pm)

NAME
Module::Loaded - mark modules as loaded or unloaded SYNOPSIS
use Module::Loaded; $bool = mark_as_loaded('Foo'); # Foo.pm is now marked as loaded $loc = is_loaded('Foo'); # location of Foo.pm set to the # loaders location eval "require 'Foo'"; # is now a no-op $bool = mark_as_unloaded('Foo'); # Foo.pm no longer marked as loaded eval "require 'Foo'"; # Will try to find Foo.pm in @INC DESCRIPTION
When testing applications, often you find yourself needing to provide functionality in your test environment that would usually be provided by external modules. Rather than munging the %INC by hand to mark these external modules as loaded, so they are not attempted to be loaded by perl, this module offers you a very simple way to mark modules as loaded and/or unloaded. FUNCTIONS
$bool = mark_as_loaded( PACKAGE ); Marks the package as loaded to perl. "PACKAGE" can be a bareword or string. If the module is already loaded, "mark_as_loaded" will carp about this and tell you from where the "PACKAGE" has been loaded already. $bool = mark_as_unloaded( PACKAGE ); Marks the package as unloaded to perl, which is the exact opposite of "mark_as_loaded". "PACKAGE" can be a bareword or string. If the module is already unloaded, "mark_as_unloaded" will carp about this and tell you the "PACKAGE" has been unloaded already. $loc = is_loaded( PACKAGE ); "is_loaded" tells you if "PACKAGE" has been marked as loaded yet. "PACKAGE" can be a bareword or string. It returns falls if "PACKAGE" has not been loaded yet and the location from where it is said to be loaded on success. BUG REPORTS
Please report bugs or other issues to <bug-module-loaded@rt.cpan.org<gt>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. perl v5.12.1 2010-04-26 Module::Loaded(3pm)