X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=trc6500-master-file%2Fscript%2Fconfigure_switch.tcl;fp=trc6500-master-file%2Fscript%2Fconfigure_switch.tcl;h=4d34d434d431979317c3891e33d21a11334acacf;hb=7cf8d4b77c1be839986f26cbd946ba28ae6a464e;hp=0000000000000000000000000000000000000000;hpb=1a388d7d89aa3e2b3333b71829e02c68003c886b;p=debian6500.git diff --git a/trc6500-master-file/script/configure_switch.tcl b/trc6500-master-file/script/configure_switch.tcl new file mode 100755 index 0000000..4d34d43 --- /dev/null +++ b/trc6500-master-file/script/configure_switch.tcl @@ -0,0 +1,52 @@ +#!/usr/bin/expect + +# ============================================================================ +# +# Copyright (C) THALES. All rights reserved +# Author: Laurent Mazet +# +# Script de configuration du switchs +# +# 2013-10-10 V1.0 : Creation +# +# ============================================================================ + +set host [lrange $argv 0 0] +if { $host == "" } { + puts "usage: configure_switch.tcl \[sw1|sw2|swg1|swg2|swm\]" + exit 1 +} + +set tftpserver "" +if { $host == "swg1" } { set tftpserver "10.133.26.160" } +if { $host == "swg2" } { set tftpserver "10.133.26.160" } +if { $host == "swm" } { set tftpserver "10.133.28.160" } +if { $host == "sw1" } { set tftpserver "10.133.26.160" } +if { $host == "sw2" } { set tftpserver "10.133.26.160" } +if { $tftpserver == "" } { puts "unknown switch '$host'"; exit } + +set date [ exec date +%Y%m%d-%H:%m:%S ] +set backup "$host-$date.txt" + +spawn telnet $host + +set timeout 30 + +expect { + "Password:" { send "thales\r" } + incorrect { send_user "invalid password or account\n"; exit 1 } + timeout { send_user "connection to $host timed out\n"; exit 1 } + eof { send_user "connection to host failed\n"; exit 1 } +} +expect -exact ">" { send "enable\r" } +expect "Password:" { send "thales\r" } +expect "#" { send "copy running-config tftp://$tftpserver/$backup\r" } +expect -exact "?" { send "$tftpserver\r" } +expect -exact "?" { send "$backup\r" } +expect "#" { send "copy tftp://$tftpserver/$host.txt startup-config\r" } +expect -exact "?" { send "startup-config\r" } +#expect "#" { send_user " << reload or exit ? >> "; interact } +expect "#" { send "reload\r" } + +exit 0 +# vim:set tabstop=4 expandtab shiftwidth=4: