05-09-2013 06:56 PM - edited 03-11-2019 06:41 PM
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
05-12-2013 12:24 PM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide