3 # ============================================================================
5 # Copyright (C) THALES. All rights reserved
6 # Author: Laurent Mazet
8 # Script de configuration du switchs
10 # 2013-10-10 V1.0 : Creation
12 # ============================================================================
14 set host
[lrange $argv 0 0]
16 puts "usage: configure_switch.tcl \[sw1|sw2|swg1|swg2|swm\]"
21 if { $host == "swg1" } { set tftpserver
"10.133.26.160" }
22 if { $host == "swg2" } { set tftpserver
"10.133.26.160" }
23 if { $host == "swm" } { set tftpserver
"10.133.28.160" }
24 if { $host == "sw1" } { set tftpserver
"10.133.26.160" }
25 if { $host == "sw2" } { set tftpserver
"10.133.26.160" }
26 if { $tftpserver == "" } { puts "unknown switch '$host'"; exit }
28 set date
[ exec date
+%Y
%m
%d-
%H
:%m
:%S
]
29 set backup
"$host-$date.txt"
36 "Password:" { send "thales\r" }
37 incorrect
{ send_user
"invalid password or account\n"; exit 1 }
38 timeout
{ send_user
"connection to $host timed out\n"; exit 1 }
39 eof { send_user
"connection to host failed\n"; exit 1 }
41 expect
-exact ">" { send "enable\r" }
42 expect
"Password:" { send "thales\r" }
43 expect
"#" { send "copy running-config tftp://$tftpserver/$backup\r" }
44 expect
-exact "?" { send "$tftpserver\r" }
45 expect
-exact "?" { send "$backup\r" }
46 expect
"#" { send "copy tftp://$tftpserver/$host.txt startup-config\r" }
47 expect
-exact "?" { send "startup-config\r" }
48 #expect "#" { send_user " << reload or exit ? >> "; interact }
49 expect
"#" { send "reload\r" }
52 # vim:set tabstop=4 expandtab shiftwidth=4: