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
, see
<http
://www.gnu.org
/licenses
/>.
18 #
Connect to
ARG using rlogin. This is
for systems using rlogin to
19 # braindead targets. It returns either the spawn_id or a
-1.
21 proc rlogin_open
{ arg } {
27 if {[board_info $
arg exists fileid
]} {
28 return [board_info $
arg fileid
]
31 #
get the hostname and port number from the config array
32 if {[board_info $
arg exists netport
]} {
33 set hostname
[lindex
[split
[board_info $
arg netport
] ":"] 0]
38 if {![board_info $
arg exists shell_prompt
]} {
39 #
if no prompt
, then set it to something generic
40 set shell_prompt
".*> "
42 set shell_prompt
[board_info $
arg shell_prompt
]
45 if {[board_info $
arg exists fileid
]} {
46 unset board_info
($
arg,fileid
)
48 #
get the right version of rlogin
49 if {![board_info $
arg exists rlogin_prog
]} {
52 set RLOGIN
[board_info $
arg rlogin_prog
]
55 # start connection and store the spawn_id
56 verbose
"Opening a $RLOGIN connection to $hostname" 2
57 spawn $RLOGIN $hostname
58 if { $spawn_id
< 0 } {
59 perror
"invalid spawn id from rlogin"
62 set board_info
($
arg,fileid
) $spawn_id
64 # Try to
connect to the target. We give up after
3 attempts.
65 while { $tries
<= 3 } {
67 -re
".*$shell_prompt.*$" {
68 verbose
"Got prompt\n"
72 -re
{TERM
= .
*\
)[ ]*$
} {
75 "Terminal type is*$" {
76 verbose
"rlogin: set the terminal to dumb" 2
79 warning
"rlogin: couldn't set terminmal type"
86 perror
"rlogin: unknown host"
89 "has logged on from" {
93 verbose
"rlogin: connected, got terminal prompt" 2
97 -re
"Maximum number of users already logged in.*$" {
98 warning
"rlogin: maximum number of users already logged in"
100 -re
"Sorry, shell is locked.*Connection closed.*$" {
101 warning
"rlogin: lready connected."
103 -re
"Sorry, this system is engaged.*Connection closed.*$" {
104 warning
"rlogin: system engaged."
107 warning
"rlogin: timed out trying to connect."
110 perror
"rlogin: got EOF while trying to connect."
117 # see
if we maxed out
on errors
119 catch
"close -i $spawn_id"
120 catch
"wait -i $spawn_id"
123 verbose
"rlogin: connected to $hostname" 2
129 # Start CMDLINE running
on DEST.
Return the shell_id associated with
132 proc rlogin_spawn
{ dest cmdline
} {
133 if {![board_info $dest
exists shell_prompt
]} {
134 set shell_prompt
"(^|\[\r\n\])\[^\r\n\]*>"
136 set shell_prompt
[board_info $dest shell_prompt
]
140 for { set i
0 } {$i
<= 2 && ! $ok
} { incr i
} {
141 set shell_id
[remote_open $dest
]
142 if { $shell_id ne
"" && $shell_id > 0 } {
143 remote_send $dest
"echo k\r"
144 remote_expect $dest
20 {
146 set shell_prompt
{\
(gdb\
)}
147 # gdb uses
'shell command'.
151 -re
".*$shell_prompt" {
163 return "unable to start command"
165 remote_send $dest
"$prefix$cmdline\n"
166 return [board_info $dest fileid
]