30 |
global timeout |
global timeout |
31 |
global board_info |
global board_info |
32 |
|
|
33 |
set raw 0; |
set raw 0 |
34 |
|
|
35 |
if { [llength $args] > 0 } { |
if { [llength $args] > 0 } { |
36 |
if { [lindex $args 0] == "raw" } { |
if { [lindex $args 0] == "raw" } { |
37 |
set raw 1; |
set raw 1 |
38 |
} |
} |
39 |
} |
} |
40 |
|
|
46 |
} |
} |
47 |
|
|
48 |
if [board_info $connhost exists hostname] { |
if [board_info $connhost exists hostname] { |
49 |
set hostname [board_info $connhost hostname]; |
set hostname [board_info $connhost hostname] |
50 |
} |
} |
51 |
|
|
52 |
if [file exists /usr/kerberos/bin/telnet] { |
if [file exists /usr/kerberos/bin/telnet] { |
53 |
set telnet /usr/kerberos/bin/telnet; |
set telnet /usr/kerberos/bin/telnet |
54 |
} else { |
} else { |
55 |
set telnet telnet; |
set telnet telnet |
56 |
} |
} |
57 |
|
|
58 |
# Instead of unsetting it, let's return it. One connection at a |
# Instead of unsetting it, let's return it. One connection at a |
59 |
# time, please. |
# time, please. |
60 |
if [board_info $connhost exists fileid] { |
if [board_info $connhost exists fileid] { |
61 |
return [board_info $connhost fileid]; |
return [board_info $connhost fileid] |
62 |
} |
} |
63 |
# get the hostname and port number from the config array |
# get the hostname and port number from the config array |
64 |
if [board_info $connhost exists netport] { |
if [board_info $connhost exists netport] { |
81 |
|
|
82 |
set tries 0 |
set tries 0 |
83 |
set result -1 |
set result -1 |
84 |
set need_respawn 1; |
set need_respawn 1 |
85 |
verbose "Starting a telnet connection to $hostname:$port $shell_prompt" 2 |
verbose "Starting a telnet connection to $hostname:$port $shell_prompt" 2 |
86 |
while { $result < 0 && $tries <= 3 } { |
while { $result < 0 && $tries <= 3 } { |
87 |
if { $need_respawn } { |
if { $need_respawn } { |
88 |
set need_respawn 0; |
set need_respawn 0 |
89 |
spawn $telnet $hostname $port; |
spawn $telnet $hostname $port |
90 |
} |
} |
91 |
expect { |
expect { |
92 |
"Trying " { |
"Trying " { |
93 |
exp_continue; |
exp_continue |
94 |
} |
} |
95 |
-re "$shell_prompt.*$" { |
-re "$shell_prompt.*$" { |
96 |
verbose "Got prompt\n" |
verbose "Got prompt\n" |
98 |
} |
} |
99 |
-re "nt Name:|ogin:" { |
-re "nt Name:|ogin:" { |
100 |
if [board_info $connhost exists telnet_username] { |
if [board_info $connhost exists telnet_username] { |
101 |
exp_send "[board_info $connhost telnet_username]\n"; |
exp_send "[board_info $connhost telnet_username]\n" |
102 |
exp_continue; |
exp_continue |
103 |
} |
} |
104 |
if [board_info $connhost exists username] { |
if [board_info $connhost exists username] { |
105 |
exp_send "[board_info $connhost username]\n"; |
exp_send "[board_info $connhost username]\n" |
106 |
exp_continue; |
exp_continue |
107 |
} |
} |
108 |
perror "telnet: need to login" |
perror "telnet: need to login" |
109 |
break |
break |
110 |
} |
} |
111 |
"assword:" { |
"assword:" { |
112 |
if [board_info $connhost exists telnet_password] { |
if [board_info $connhost exists telnet_password] { |
113 |
exp_send "[board_info $connhost telnet_password]\n"; |
exp_send "[board_info $connhost telnet_password]\n" |
114 |
exp_continue; |
exp_continue |
115 |
} |
} |
116 |
if [board_info $connhost exists password] { |
if [board_info $connhost exists password] { |
117 |
exp_send "[board_info $connhost password]\n"; |
exp_send "[board_info $connhost password]\n" |
118 |
exp_continue; |
exp_continue |
119 |
} |
} |
120 |
perror "telnet: need a password" |
perror "telnet: need a password" |
121 |
break |
break |
122 |
} |
} |
123 |
-re "advance.*y/n.*\\?" { |
-re "advance.*y/n.*\\?" { |
124 |
exp_send "n\n"; |
exp_send "n\n" |
125 |
exp_continue; |
exp_continue |
126 |
} |
} |
127 |
-re {([Aa]dvanced|[Ss]imple) or ([Ss]imple|[Aa]dvanced)} { |
-re {([Aa]dvanced|[Ss]imple) or ([Ss]imple|[Aa]dvanced)} { |
128 |
exp_send "simple\n"; |
exp_send "simple\n" |
129 |
exp_continue; |
exp_continue |
130 |
} |
} |
131 |
"Connected to" { |
"Connected to" { |
132 |
exp_continue |
exp_continue |
137 |
break |
break |
138 |
} |
} |
139 |
"VxWorks Boot" { |
"VxWorks Boot" { |
140 |
exp_send "@\n"; |
exp_send "@\n" |
141 |
sleep 20; |
sleep 20 |
142 |
exp_continue; |
exp_continue |
143 |
} |
} |
144 |
-re "Escape character is.*\\.\[\r\n\]" { |
-re "Escape character is.*\\.\[\r\n\]" { |
145 |
if { $raw || [board_info $connhost exists dont_wait_for_prompt] } { |
if { $raw || [board_info $connhost exists dont_wait_for_prompt] } { |
146 |
set result 0; |
set result 0 |
147 |
} else { |
} else { |
148 |
if [board_info $connhost exists send_initial_cr] { |
if [board_info $connhost exists send_initial_cr] { |
149 |
exp_send "\n" |
exp_send "\n" |
159 |
break |
break |
160 |
} |
} |
161 |
-re "Connection refused.*$" { |
-re "Connection refused.*$" { |
162 |
catch "exp_send \"\003\"" foo; |
catch "exp_send \"\003\"" foo |
163 |
sleep 5; |
sleep 5 |
164 |
warning "telnet: connection refused." |
warning "telnet: connection refused." |
165 |
} |
} |
166 |
-re "Sorry, this system is engaged.*" { |
-re "Sorry, this system is engaged.*" { |
179 |
} |
} |
180 |
eof { |
eof { |
181 |
warning "telnet: got unexpected EOF from telnet." |
warning "telnet: got unexpected EOF from telnet." |
182 |
catch close; |
catch close |
183 |
catch wait; |
catch wait |
184 |
set need_respawn 1; |
set need_respawn 1 |
185 |
sleep 5; |
sleep 5 |
186 |
} |
} |
187 |
} |
} |
188 |
incr tries |
incr tries |
211 |
# |
# |
212 |
proc telnet_binary { hostname } { |
proc telnet_binary { hostname } { |
213 |
if [board_info $hostname exists fileid] { |
if [board_info $hostname exists fileid] { |
214 |
remote_send $hostname ""; |
remote_send $hostname "" |
215 |
remote_expect $hostname 5 { |
remote_expect $hostname 5 { |
216 |
-re "telnet> *$" {} |
-re "telnet> *$" {} |
217 |
default {} |
default {} |
219 |
remote_send $hostname "set binary\n" |
remote_send $hostname "set binary\n" |
220 |
remote_expect $hostname 5 { |
remote_expect $hostname 5 { |
221 |
-re "Format is .*telnet> *$" { |
-re "Format is .*telnet> *$" { |
222 |
remote_send $hostname "toggle binary\n"; |
remote_send $hostname "toggle binary\n" |
223 |
exp_continue; |
exp_continue |
224 |
} |
} |
225 |
-re "Negotiating network ascii.*telnet> *$" { |
-re "Negotiating network ascii.*telnet> *$" { |
226 |
remote_send $hostname "toggle binary\n"; |
remote_send $hostname "toggle binary\n" |
227 |
exp_continue; |
exp_continue |
228 |
} |
} |
229 |
-re "Negotiating binary.*\[\r\n\].*$" { } |
-re "Negotiating binary.*\[\r\n\].*$" { } |
230 |
-re "binary.*unknown argument.*telnet> *$" { |
-re "binary.*unknown argument.*telnet> *$" { |
231 |
remote_send $hostname "mode character\n"; |
remote_send $hostname "mode character\n" |
232 |
} |
} |
233 |
-re "Already operating in binary.*\[\r\n\].*$" { } |
-re "Already operating in binary.*\[\r\n\].*$" { } |
234 |
timeout { |
timeout { |
239 |
} |
} |
240 |
|
|
241 |
proc telnet_transmit { dest file args } { |
proc telnet_transmit { dest file args } { |
242 |
return [standard_transmit $dest $file]; |
return [standard_transmit $dest $file] |
243 |
} |
} |