Expect, telnet, frozen console.
From: Gavin McDonald (gavin_at_advanceforklift.com)
Date: 03/29/04
- Next message: Darren New: "Re: % operator incompatibility..."
- Previous message: Volker Hetzer: "% operator incompatibility..."
- Next in thread: Gavin McDonald: "Re: Expect, telnet, frozen console."
- Reply: Gavin McDonald: "Re: Expect, telnet, frozen console."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 19:47:53 GMT
Hi all.
I have Expect v5.38.0/tcl v8.4 on linux 2.4.20 - Slackware 9.0.
I have a simple task I wish to automate:
telnet into remote host, provide username/password, surrender control to
user. This script will eventually be tied into /etc/inittab so that it
can be run in multiple consoles. (Another question in its own time.) The
script is called with a character and a tty as arguments. The script,
quoted below, works but hangs in a specific situation;
#!/usr/bin/expect --
log_user 0
set stty_init "sane cs8 -istrip"
spawn -nottycopy -nottyinit telnet $HOST
set tty_spawn_id /dev/[lrange $argv 1 1]
expect login
send "$USER[lrange $argv 0 0]\r"
expect Password
send "$PASSWORD\r"
log_user 1
interact eof
For each $USER on $HOST there are [a..j] logins, named [$USERa..$USERj].
the command:
# autologin b tty2
logs in to $HOST as $USERb. the .profile for said user starts a custom
app called 'loe' which presents a login screen in 80x24 ASCII a la
ncurses. (NOT ncurses tho...) from this point, I can login, use the app,
and all the f-keys, CTRL sequences etc work fine. To back out of a
screen, the user presses ESC, which also works fine. However, when the
user presses ESC to back out of the main menu, to the login screen, All
I/O stops. The cursor disappears, and no further input is accepted. The
processes stay active however, and if I 'kill -HUP' the telnet process,
expect exits cleanly. If I telnet manually to the host, this problem
does not happen at all.
I have compared the output of 'env' for the telnet, and the expect
logins, and they are identical. It is as though the "login" screen that
is displayed sends a control character which takes expect out of the
"interact" command.
I have, on occasion, been able to avoid this by pressing ESC twice, (or
ESC,ENTER) with enough speed that they transmit before the screen
redraws. I have also tried removing "eof" from interact, but still the
problem persists.
The "set stty_init ..." line is an attempt to solve the problem as was
done here: http://tinyurl.com/ytpse which met with limited, (though
unrepeatable,) success. The line "set tty_spawn_id" was yet another
attempt to fix the problem, again unsuccessfully. (Now I leave it as an
artifact for adding the aforementioned virtual terminal support.)
I now turn to the sages at c.l.t in hopes that someone has seen this
before, or knows where to turn.
One last thing: I have been in contact with tier 1 support for the
'loe' people, and they were unable/unwilling to furnish further details
on the output of their login screen.
Thanks for your help,
Gavin McDonald.
- Next message: Darren New: "Re: % operator incompatibility..."
- Previous message: Volker Hetzer: "% operator incompatibility..."
- Next in thread: Gavin McDonald: "Re: Expect, telnet, frozen console."
- Reply: Gavin McDonald: "Re: Expect, telnet, frozen console."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|