1
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2
# 2001, 2002, 2003 Free Software Foundation, Inc.
4
# This file is part of DejaGnu.
6
# DejaGnu is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# DejaGnu is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with DejaGnu; if not, write to the Free Software Foundation,
18
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
# Connect to ARG using rlogin. This is for systems using rlogin to
22
# braindead targets. It returns either the spawn_id or a -1.
25
proc rlogin_open { arg } {
31
if [board_info $arg exists fileid] {
32
return [board_info $arg fileid]
35
# get the hostname and port number from the config array
36
if [board_info $arg exists netport] {
37
set hostname [lindex [split [board_info $arg netport] ":"] 0]
42
if ![board_info $arg exists shell_prompt] {
43
# if no prompt, then set it to something generic
44
set shell_prompt ".*> "
46
set shell_prompt [board_info $arg shell_prompt]
49
if [board_info $arg exists fileid] {
50
unset board_info($arg,fileid)
52
# get the right version of rlogin
53
if ![board_info $arg exists rlogin_prog] {
56
set RLOGIN [board_info $arg rlogin_prog]
59
# start connection and store the spawn_id
60
verbose "Opening a $RLOGIN connection to $hostname" 2
61
spawn $RLOGIN $hostname
62
if { $spawn_id < 0 } {
63
perror "invalid spawn id from rlogin"
66
set board_info($arg,fileid) $spawn_id
68
# Try to connect to the target. We give up after 3 attempts.
69
while { $tries <= 3 } {
71
-re ".*$shell_prompt.*$" {
72
verbose "Got prompt\n"
76
-re "TERM = .*\\)\[ ]*$" {
79
"Terminal type is*$" {
80
verbose "rlogin: set the terminal to dumb" 2
83
warning "rlogin: couldn't set terminmal type"
90
perror "rlogin: unknown host"
93
"has logged on from" {
97
verbose "rlogin: connected, got terminal prompt" 2
101
-re "Maximum number of users already logged in.*$" {
102
warning "rlogin: maximum number of users already logged in"
104
-re "Sorry, shell is locked.*Connection closed.*$" {
105
warning "rlogin: lready connected."
107
-re "Sorry, this system is engaged.*Connection closed.*$" {
108
warning "rlogin: system engaged."
111
warning "rlogin: timed out trying to connect."
114
perror "rlogin: got EOF while trying to connect."
121
# see if we maxed out on errors
123
catch "close -i $spawn_id"
124
catch "wait -i $spawn_id"
127
verbose "rlogin: connected to $hostname" 2
134
# Start CMDLINE running on DEST. Return the shell_id associated with
137
proc rlogin_spawn { dest cmdline } {
138
if ![board_info $dest exists shell_prompt] {
139
set shell_prompt "(^|\[\r\n\])\[^\r\n\]*>"
141
set shell_prompt [board_info $dest shell_prompt]
145
for { set i 0 } {$i <= 2 && ! $ok} { incr i } {
146
set shell_id [remote_open $dest]
147
if { $shell_id != "" && $shell_id > 0 } {
148
remote_send $dest "echo k\r"
149
remote_expect $dest 20 {
151
set shell_prompt "\\(gdb\\)"
152
# gdb uses 'shell command'.
156
-re ".*$shell_prompt" {
168
return "unable to start command"
170
remote_send $dest "${prefix}${cmdline}\n"
171
return [board_info $dest fileid]