X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=simple-cdd%2Fadditional_scripts%2Fset_mediatray.tcl;fp=simple-cdd%2Fadditional_scripts%2Fset_mediatray.tcl;h=02f76b210004760274dde35a6a4e360bf47ae5f5;hb=b3f3562f417f2983a7e0d0c2d5b54bb3bd9e94ab;hp=0000000000000000000000000000000000000000;hpb=40346f7c7585854238262f7b8ca4b5a0e5c5f0b4;p=debian6500.git diff --git a/simple-cdd/additional_scripts/set_mediatray.tcl b/simple-cdd/additional_scripts/set_mediatray.tcl new file mode 100755 index 0000000..02f76b2 --- /dev/null +++ b/simple-cdd/additional_scripts/set_mediatray.tcl @@ -0,0 +1,86 @@ +#!/usr/bin/expect + +# ============================================================================ +# +# Copyright (C) THALES. All rights reserved +# Author: Laurent Mazet +# +# Script de connection au switchs +# +# 2014-10-06 V1.0 : Creation +# +# ============================================================================ + +# default value +set blade {0} +set host "" +set login "admin" +set password "thalescom02" +set prompt "system>" + +proc usage {script_name rc} { + puts "usage: [exec basename $script_name] \[host\] \[-b blade\] \[-h\] \[-l login\] \[-p password\] \[-x prompt\]" + exit $rc +} + +# process argument +set action "" +for {set i 0} {$i < [llength $argv]} {incr i} { + set arg [lindex $argv $i] + switch $arg { + -b { set action "-blade" } + -h { usage $argv0 0 } + -l { set action "-login" } + -p { set action "-password" } + -x { set action "-prompt" } + default { + switch $action { + -blade { set blade $arg } + -login { set login $arg } + -password { set password $arg } + -prompt { set prompt $arg } + default { set host $arg } + } + set action "" + } + } +} +if {$action != ""} { + puts "missing arguments" + exit 1 +} +if { $host == "" } { + usage $argv0 1 +} + +# start connection +spawn telnet $host + +# login +expect { + "username:" { send "$login\r" } + timeout { send_user "connection to host failed\n"; exit 1 } + eof { send_user "connection to host failed\n"; exit 1 } +} + + +# password +expect { + "password:" { send "$password\r" } + timeout { send_user "connection to host failed\n"; exit 1 } + eof { send_user "connection to host failed\n"; exit 1 } +} + +expect { + "$prompt" { send "mt -b $blade\r" } + "username:" { send_user "connection to host failed\n"; exit 1 } +} + +expect { + "OK" { send "exit\r" } + "$prompt" { send_user "error\n"; exit 1 } +} + +send_user "\n" +exit 0 +# vim:set tabstop=4 shiftwidth=4 softtabstop=4: