1 # Copyright
(C
) 1992-2019, 2020 Free Software Foundation
, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software
; you can redistribute it and
/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
; either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # DejaGnu is distributed in the hope that it will be useful
, but
11 # WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu
; if not
, write to the Free Software Foundation
,
17 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
19 #
Connect to
ARG using rlogin. This is
for systems using rlogin to
20 # braindead targets. It returns either the spawn_id or a
-1.
22 proc rlogin_open
{ arg } {
28 if {[board_info $
arg exists fileid
]} {
29 return [board_info $
arg fileid
]
32 #
get the hostname and port number from the config array
33 if {[board_info $
arg exists netport
]} {
34 set hostname
[lindex
[split
[board_info $
arg netport
] ":"] 0]
39 if {![board_info $
arg exists shell_prompt
]} {
40 #
if no prompt
, then set it to something generic
41 set shell_prompt
".*> "
43 set shell_prompt
[board_info $
arg shell_prompt
]
46 if {[board_info $
arg exists fileid
]} {
47 unset board_info
($
arg,fileid
)
49 #
get the right version of rlogin
50 if {![board_info $
arg exists rlogin_prog
]} {
53 set RLOGIN
[board_info $
arg rlogin_prog
]
56 # start connection and store the spawn_id
57 verbose
"Opening a $RLOGIN connection to $hostname" 2
58 spawn $RLOGIN $hostname
59 if { $spawn_id
< 0 } {
60 perror
"invalid spawn id from rlogin"
63 set board_info
($
arg,fileid
) $spawn_id
65 # Try to
connect to the target. We give up after
3 attempts.
66 while { $tries
<= 3 } {
68 -re
".*$shell_prompt.*$" {
69 verbose
"Got prompt\n"
73 -re
{TERM
= .
*\
)[ ]*$
} {
76 "Terminal type is*$" {
77 verbose
"rlogin: set the terminal to dumb" 2
80 warning
"rlogin: couldn't set terminmal type"
87 perror
"rlogin: unknown host"
90 "has logged on from" {
94 verbose
"rlogin: connected, got terminal prompt" 2
98 -re
"Maximum number of users already logged in.*$" {
99 warning
"rlogin: maximum number of users already logged in"
101 -re
"Sorry, shell is locked.*Connection closed.*$" {
102 warning
"rlogin: lready connected."
104 -re
"Sorry, this system is engaged.*Connection closed.*$" {
105 warning
"rlogin: system engaged."
108 warning
"rlogin: timed out trying to connect."
111 perror
"rlogin: got EOF while trying to connect."
118 # see
if we maxed out
on errors
120 catch
"close -i $spawn_id"
121 catch
"wait -i $spawn_id"
124 verbose
"rlogin: connected to $hostname" 2
130 # Start CMDLINE running
on DEST.
Return the shell_id associated with
133 proc rlogin_spawn
{ dest cmdline
} {
134 if {![board_info $dest
exists shell_prompt
]} {
135 set shell_prompt
"(^|\[\r\n\])\[^\r\n\]*>"
137 set shell_prompt
[board_info $dest shell_prompt
]
141 for { set i
0 } {$i
<= 2 && ! $ok
} { incr i
} {
142 set shell_id
[remote_open $dest
]
143 if { $shell_id ne
"" && $shell_id > 0 } {
144 remote_send $dest
"echo k\r"
145 remote_expect $dest
20 {
147 set shell_prompt
{\
(gdb\
)}
148 # gdb uses
'shell command'.
152 -re
".*$shell_prompt" {
164 return "unable to start command"
166 remote_send $dest
"$prefix$cmdline\n"
167 return [board_info $dest fileid
]