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