correct issue with trc6500-webconfig package installation
[debian6500.git] / trc6500-master-file / script / set_mediatray.tcl
CommitLineData
b3f3562f
OL
1#!/usr/bin/expect
2
3# ============================================================================
4#
5# Copyright (C) THALES. All rights reserved
6# Author: Laurent Mazet
7#
8# Script de connection au switchs
9#
10# 2014-10-06 V1.0 : Creation
11#
12# ============================================================================
13
14# default value
15set blade {0}
16set host ""
17set login "admin"
18set password "thalescom02"
19set prompt "system>"
20
21proc usage {script_name rc} {
22 puts "usage: [exec basename $script_name] \[host\] \[-b blade\] \[-h\] \[-l login\] \[-p password\] \[-x prompt\]"
23 exit $rc
24}
25
26# process argument
27set action ""
28for {set i 0} {$i < [llength $argv]} {incr i} {
29 set arg [lindex $argv $i]
30 switch $arg {
31 -b { set action "-blade" }
32 -h { usage $argv0 0 }
33 -l { set action "-login" }
34 -p { set action "-password" }
35 -x { set action "-prompt" }
36 default {
37 switch $action {
38 -blade { set blade $arg }
39 -login { set login $arg }
40 -password { set password $arg }
41 -prompt { set prompt $arg }
42 default { set host $arg }
43 }
44 set action ""
45 }
46 }
47}
48if {$action != ""} {
49 puts "missing arguments"
50 exit 1
51}
52if { $host == "" } {
53 usage $argv0 1
54}
55
56# start connection
57spawn telnet $host
58
59# login
60expect {
61 "username:" { send "$login\r" }
62 timeout { send_user "connection to host failed\n"; exit 1 }
63 eof { send_user "connection to host failed\n"; exit 1 }
64}
65
66
67# password
68expect {
69 "password:" { send "$password\r" }
70 timeout { send_user "connection to host failed\n"; exit 1 }
71 eof { send_user "connection to host failed\n"; exit 1 }
72}
73
74expect {
75 "$prompt" { send "mt -b $blade\r" }
76 "username:" { send_user "connection to host failed\n"; exit 1 }
77}
78
79expect {
80 "OK" { send "exit\r" }
81 "$prompt" { send_user "error\n"; exit 1 }
82}
83
84send_user "\n"
85exit 0
86# vim:set tabstop=4 shiftwidth=4 softtabstop=4: