[rancid] Re: Using Rancid to pus DST changes
Robin Mordasiewicz
rmordasiewicz at samuelmanutech.com
Wed Mar 7 20:43:23 UTC 2007
On Wed, 7 Mar 2007, Todd Heide wrote:
> How can I use (if I can) rancid to push a configuration change for the DST to all the routers? Basically it is one line,
> clock summer-time CST recurring 2 Sun Mar 2:00 1 Sun Nov 2:00
One thing you can use is expect. Here is a simple example expect script
which you can run on each router which looping through your router.db file
[ myusername at localhost ]$ expect -f summertime_DST.exp myrouter.mydomain.com
< summertime_DST.exp >
#!/usr/bin/expect -f
#
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
set userid "myusername"
set vtypasswd "mypassword"
set rtr [lindex $argv 0]
spawn telnet $rtr
match_max 100000
expect {
{Username} { send "$userid\r"
expect {
{*Password*} { send "$vtypasswd\r" }
}
}
{telnet>} { send_user "$rtr - telnet failed\n"
exit
}
{Password} { send "$vtypasswd\r" }
}
send -- "conf t\r"
send -- "clock summer-time $DST_timezone recurring 2 Sun Mar 2:00 1 Sun Nov 2:00\r"
send -- "wr mem\r"
send -- "end\r"
send -- "exit\r"
expect eof
< /summertime_DST.exp >
More information about the Rancid-discuss
mailing list