I'm working on a script to automatize instructions on an IOS Cisco router, using the expect commands.
Here is the script I wrote:
#!/bin/expect
#log_user 0
set timeout 60
set mode [lindex $argv 0]
spawn ssh myuser@10.0.0.254
expect "*assword:" {
send "mypassword\r"
}
expect "*>" {
send "enable \r"
}
expect "*#" {
send "conf t \r"
}
expect "*(config)" {
send "interface Serial0/0/0 \r"
send "clock rate 14400\r"
}
My problem is, this script stops at the "router1(config)#" state.
But if I put an interact
command at the end of my script, all of this is working correctly. The user correctly get into the interface config mode and the clock rate is well updated.
But the fact is, I don't want the user to interact.
So I really do not understand what is going on and why I cannot just end the script like that...
If you have any clues... ?