Since I've discovered Expect, I've had big plans for using it
to get information out of our ancient VAX systems and into the
more familiar confines of HP-UX 10.2 (I'm just a user, not an
administrator or programmer per se; I only have access to this
information through the programs provided on the VAX). However,
I've run into a snag right off the bat.
I've included below the script, followed the output as normally
seen, followed by the output with 'exp_internal 1' turned on.
What you can't see from this is the long time it takes after
the script sends the password, compared to how long it takes
when I telnet manually.
I've tried different terminal settings (vt102, vt200, vt220),
with the same results. I've also checked the Monkey Book and
every FAQ I could find, along with several AltaVista searches,
(which is not to say the answer isn't somewhere - I just need
to get running ASAP).
TIA,
Mark Krautheim
GE Aircraft Engines
Rutland, Vermont
************************************************************
************** EXPECT SCRIPT FOLLOWS ********************
************************************************************
#!/usr/local/bin/expect
set timeout -1
set env(TERM) "vt100"
spawn telnet cndvax
puts "term = $env(TERM)"
#exp_internal 1
expect "Username:" { send "usfs\r" }
expect "Password:" { send "******\r" }
expect "Please enter"
interact
************************************************************
************** NORMAL OUTPUT FOLLOWS ********************
************************************************************
bin$ family_tree.exp
spawn telnet cndvax
term = vt100
Trying...
Connected to cndvax.ae.ge.com.
Escape character is '^]'.
Local flow control off
Connected to CNDVAX
Username: usfs
Password:
<# My comment: the program sits here for a long time>
<# My comment: I don't get the messages below when I do the>
<# My comment: entire telnet session interactively>
%SET-W-NOTSET, error modifying NTY2067:
-SET-I-UNKTERM, unknown terminal type
*****************************************************************
*** ***
*** To assist anyone in identifying any printer output ***
*** generated by this User ID, you will be asked to enter ***
*** your own name. PLEASE cooperate by providing your ***
*** complete last name and first and middle initials when ***
*** prompted for. ***
*** ***
*****************************************************************
Please enter your last name:
Please enter your last name:
Please enter your last name:
Please enter your last name:
Please enter your last name:
Please enter your last name:
Please enter your last name:
************************************************************
********** DEBUGGING OUTPUT FOLLOWS ********************
************************************************************
bin$ expect family_tree.exp
spawn telnet cndvax
term = vt100
expect: does "" (spawn_id 5) match glob pattern "Username:"? no
Trying...
Connected to cndvax.ae.ge.com.
Escape character is '^]'.
expect: does "Trying...\r\nConnected to cndvax.ae.ge.com.\r\nEscape
character is '^]'.\r\n" (spawn_id 5) match glob pattern "Username:"? no
Local flow control off
expect: does "Trying...\r\nConnected to cndvax.ae.ge.com.\r\nEscape
character is '^]'.\r\nLocal flow control off\r\n" (spawn_id 5) match
glob pattern "Username:"? no
Connected to CNDVAX
expect: does "Trying...\r\nConnected to cndvax.ae.ge.com.\r\nEscape
character is '^]'.\r\nLocal flow control off\r\n\x07\r\n\r\nConnected to
CNDVAX\r\n\r" (spawn_id 5) match glob pattern "Username:"? no
Username:
expect: does "Trying...\r\nConnected to cndvax.ae.ge.com.\r\nEscape
character is '^]'.\r\nLocal flow control off\r\n\x07\r\n\r\nConnected to
CNDVAX\r\n\r\n\rUsername: " (spawn_id 5) match glob pattern "Username:"?
yes
expect: set expect_out(0,string) "Username:"
expect: set expect_out(spawn_id) "5"
expect: set expect_out(buffer) "Trying...\r\nConnected to
cndvax.ae.ge.com.\r\nEscape character is '^]'.\r\nLocal flow control
off\r\n\x07\r\n\r\nConnected to CNDVAX\r\n\r\n\rUsername:"
send: sending "usfs\r" to { 5 }
expect: does " " (spawn_id 5) match glob pattern "Password:"? no
usfs
expect: does " usfs\r\n" (spawn_id 5) match glob pattern "Password:"? no
Password:
expect: does " usfs\r\n\rPassword: " (spawn_id 5) match glob pattern
"Password:"? yes
expect: set expect_out(0,string) "Password:"
expect: set expect_out(spawn_id) "5"
expect: set expect_out(buffer) " usfs\r\n\rPassword:"
send: sending "*******\r" to { 5 }
expect: does " " (spawn_id 5) match glob pattern "Please enter"? no
expect: does " \r\n \r" (spawn_id 5) match glob pattern "Please enter"?
no
expect: does " \r\n \r\x1b[c" (spawn_id 5) match glob pattern "Please
enter"? no
expect: does " \r\n \r\x1b[c\x1b\\x1bZ" (spawn_id 5) match glob pattern
"Please enter"? no
expect: does " \r\n \r\x1b[c\x1b\\x1bZ\x1b[0c" (spawn_id 5) match glob
pattern "Please enter"? no
expect: does " \r\n \r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c" (spawn_id 5) match
glob pattern "Please enter"? no
expect: does " \r\n \r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ" (spawn_id
5) match glob pattern "Please enter"? no
expect: does " \r\n \r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c"
(spawn_id 5) match glob pattern "Please enter"? no
%SET-W-NOTSET, error modifying NTY9755:
expect: does " \r\n
\r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c\r\n%SET-W-NOTSET, error
modifying NTY9755:\r" (spawn_id 5) match glob pattern "Please enter"? no
-SET-I-UNKTERM, unknown terminal type
expect: does " \r\n
\r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c\r\n%SET-W-NOTSET, error
modifying NTY9755:\r\n-SET-I-UNKTERM, unknown terminal type\r" (spawn_id
5) match glob pattern "Please enter"? no
*****************************************************************
*** ***
*** To assist anyone in identifying any printer output ***
*** generated
expect: does " \r\n
\r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c\r\n%SET-W-NOTSET, error
modifying NTY9755:\r\n-SET-I-UNKTERM, unknown terminal type\r\n\r\n
*****************************************************************\r\n
***
***\r\n *** To assist anyone in identifying any printer
output ***\r\n *** generated " (spawn_id 5) match glob
pattern "Please enter"? no
by this User ID, you will be asked to enter ***
*** your own name. PLEASE cooperate by providing your ***
*** complete last name and first and middle initials when ***
*** prompted for.
expect: does " \r\n
\r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c\r\n%SET-W-NOTSET, error
modifying NTY9755:\r\n-SET-I-UNKTERM, unknown terminal type\r\n\r\n
*****************************************************************\r\n
***
***\r\n *** To assist anyone in identifying any printer
output ***\r\n *** generated by this User ID, you will be
asked to enter ***\r\n *** your own name. PLEASE cooperate by
providing your ***\r\n *** complete last name and first and
middle initials when ***\r\n *** prompted
for. " (spawn_id 5) match glob pattern "Please
enter"? no
***
*** ***
*****************************************************************
Please enter your last name: expect: does " \r\n
\r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c\r\n%SET-W-NOTSET, error
modifying NTY9755:\r\n-SET-I-UNKTERM, unknown terminal type\r\n\r\n
*****************************************************************\r\n ***
***\r\n *** To assist anyone in identifying any printer output ***\r\n
*** generated by this User ID, you will be asked to enter ***\r\n ***
your own name. PLEASE cooperate by providing your ***\r\n *** complete
last name and first and middle initials when ***\r\n *** prompted for.
***\r\n *** ***\r\n
*****************************************************************\r\n\r\n\r\n
\rPlease enter your last name: " (spawn_id 5) match glob pattern "Please
enter"? yes expect: set expect_out(0,string) "Please enter" expect: set
expect_out(spawn_id) "5" expect: set expect_out(buffer) " \r\n
\r\x1b[c\x1b\\x1bZ\x1b[0c\x1b[c\x1b\\x1bZ\x1b[0c\r\n%SET-W-NOTSET, error
modifying NTY9755:\r\n-SET-I-UNKTERM, unknown terminal type\r\n\r\n
*****************************************************************\r\n ***
***\r\n *** To assist anyone in identifying any printer output ***\r\n
*** generated by this User ID, you will be asked to enter ***\r\n ***
your own name. PLEASE cooperate by providing your ***\r\n *** complete
last name and first and middle initials when ***\r\n *** prompted for.
***\r\n *** ***\r\n
*****************************************************************\r\n\r\n\r\n
\rPlease enter" tty_raw_noecho: was raw = 0 echo = 1 spawn id 0 sent
<\x1b[?1;2c\x1b[?1;2c\x1b[?1;2c\x1b[?1;2c\x1b[?1;2c\x1b[?1;2c> spawn id 5
sent <\r\nPlease enter your last name: >
Please enter your last name: spawn id 5 sent <\r\nPlease enter your last
name: \r\nPlease enter your last name: \r\nPlease enter your last name:
\r\nPlease enter your last name: \r\nPlease enter your last name: >
Please enter your last name:
Please enter your last name:
Please enter your last name:
Please enter your last name:
Please enter your last name:
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
VMS may be querying the "terminal", trying to determine its type. It does
this by sending a command sequence and attempting to read a return value.
The delay is VMS waiting for the timeout. VMS then writes the error message
you see above.
As for the lastname stuff, check the login scripts, LOGIN.COM, IIRC. They
(system and user) may be failing for similar or related reasons.
--
David N. Lombard
David is correct.
> > I've tried different terminal settings (vt102, vt200, vt220),
> > with the same results. I've also checked the Monkey Book and
> > every FAQ I could find, along with several AltaVista searches,
dejanews would be more appropriate than altavista - I've answered this
question. Anyway, this subject *is* in the book on page 250 (and also
read page 340). You should also read the opening example in the
"Debugging Patterns" chapter.
Don
what you have here is either in sys$manager:sylogin.com (or equiv)
or in sys$login:login.com (or equiv); there is a line something like
$ set terminal/inquire ! sets terminal characteristics
but we know that a telnet terminal does not necessarily act like a
vt200 et al and even more so when a program (Expect) is handling the
data exchange; /inquire operates by sending an escape sequence to
terminal (VMS help says default parameter is terminal equivalent to
sys$command); this can either be removed from your login or programmed
around by the system manager if in sylogin; looking at the device NTY
I'll guess this is a network tty and created by your TCP/IP package;
I have logic similar to the following which you might adapt to your
purpose (not checked out & at your risk);
$ if .not. f$getdvi( "SYS$COMMAND:", "TT_DECCRT3" )
$ then ! not a vt300 family terminal
$ devnam = f$getdvi( "sys$command:", "devnam" ) - "_" - "_"
$ devtyp = f$extract( 0, 2, devnam )
$ if devtyp .nes. "NT"
$ then
$ set terminal sys$output:/inquire
$ endif
$ endif
|> *****************************************************************
|> *** ***
|> *** To assist anyone in identifying any printer output ***
|> *** generated by this User ID, you will be asked to enter ***
|> *** your own name. PLEASE cooperate by providing your ***
|> *** complete last name and first and middle initials when ***
|> *** prompted for. ***
|> *** ***
|> *****************************************************************
|>Please enter your last name:
|>Please enter your last name:
|>Please enter your last name:
|>Please enter your last name:
|>Please enter your last name:
|>Please enter your last name:
|>Please enter your last name:
.. (big snip)
is this account captive; this looks like either that or sylogin is
running a command file as you login and it really really wants your
name; sorry but I can't tell from your post is this is also causing
problems;
--bn (Bart Nickerson)
nick...@pundit.ds.boeing.com
(206) 662-0183
David and Bart were correct -- that is a captive account I was logging into.
The 'lastname/initials' stuff was put there by our VAX administrator. He has
not much else to do other than find homes for orphaned printouts, now that
we've moved to PCs and Unix workstations.
Pretty much everything I know on this subject:
1. Whatever you're doing with Expect, look in
Don's book. No, look again. It's a real
work of art, one that can only be appreci-
ated after you've deeply tried to work
through a lot of the content yourself. It's
astonishing how much good stuff he packed
in.
2. You are going to be sooooooo happy. Every-
one I know who's ever controlled (Open)VMS
applications with Expect has talked about
saving dozens, if not hundreds, of hours
of time.
3. That terminal handshaking stuff is a nui-
sance. Everyone runs into it, and everyone
seems to solve it by copying what someone
else has done before. It's all downhill
from there.
4. Autoexpect is way useful.
--
Cameron Laird http://starbase.neosoft.com/~claird/home.html
cla...@NeoSoft.com +1 281 996 8546 FAX