cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1008
Views
0
Helpful
1
Replies

Help with Expect command to change config on hundreds of ASA's.

gregprofitt
Level 1
Level 1

Hi All,

I'm looking for some help with the Expect command to automate some tasks, I'm certainly no programmer but I am struggling, here is an example of my script.

#!/usr/bin/expect -f

#

# This simple Expect script will add a new Syslog destination in

# Cisco switches (IOS based)

# We assume here that all switches uses the same credentials

# for the administrative tasks

#

# Define variables

set password "site1"

set enablepassword "site1"

# Define all the switches to be reconfigured (separated by spaces)

set switches "site1 site2 site3"

# Main loop

foreach switch $switches {

        puts "Processing switch: $switch";

        # Open the telnet session:

        spawn telnet $switch

        # Perform authentication

        expect "Password:"

        send "$password\r"

        expect ">"

        # Switch to enable mode

        send "en\r"

        expect "Password:"

        send "$enablepassword\r"

        expect "#"

        # Enable configuration mode (terminal)

        send "conf t\r"

        expect "#"

        # Modify VLAN1

        send "interface vlan1\r"

        expect "#"

     # Change VLAN1 Description to Uppercase

        send "description INSIDE\r"

        expect "#"

        send "exit\r"

        expect "#"

        # Save config to NVRAM

        send "wr\r"

        expect "#"

        #Logging out

        send "exit\r"

        expect eof

}

In the example this works fine for SITE1 passing the credentials SITE1 as the default password and SITE1 as the enable password.  I need to do usernames and passwords that are different for each site.  I have to make some changes across hundreds of ASA's to terminating tunnels to a new location.  Can anyone help out in how to do this, I know I am close I just need it to read, siteA, username, both passwords from a text file, etc

Greg

1 Reply 1

blau grana
Level 7
Level 7

Hello,

try to modify this example to your needs ->

http://www.bitpapers.com/2012/04/cisco-changing-configurations-of-many.html

Best Regards

Please rate all helpful posts and close solved questions

Best Regards Please rate all helpful posts and close solved questions
Review Cisco Networking for a $25 gift card