i run a tcl send expect script in a file and execute as ./file
#!/usr/bin/expect
spawn -noecho telnet 42.0.1.11
set timeout 900
expect "login:"
send "admin\r"
expect "Password: "
send "ram\r"
expect "#"
for {set i 0} {$i <= 1000000000} {incr i} {
some router commands
}
this works fine until router reloads, when router reloads, this script stops as spawn id not open., i want to resume the script (i dont know exactly how much time it takes to reload as it varies most of time).,is there any way to resume the script automatically
Thanks
Wrap your login procedure into a proc and call it again if you get EOF. Here is the basic idea, just remember that there may be other ways for things to go wrong.
Edit: I have rewritten the code after some investigation. This has been tested on Linux with “router reboot” being simulated by Solaris 10 workstation (sorry no Cisco to reboot here). As I mentioned
pingimplementations differ from OS to OS soproc Pingmay need to be changed to accommodate your situation.