- To: Lucas King <lking@xxxxxxxxxxxxxxxxx>
- Subject: Re: [SLUG] automating a Telnet session using EXPECT
- From: Angus Lees <gus@xxxxxxxxxxx>
- Date: Wed Sep 4 15:51:03 2002
- Cc: slug@xxxxxxxxxxx
- Microsoft: I'm not laughing anymore.
- User-agent: Wanderlust/2.9.14 (Unchained Melody) XEmacs/21.4 (Honest Recruiter)
At Fri, 30 Aug 2002 17:46:24 +1000, Lucas King wrote:
> As i could not get satisfactory results from Expect i rewrote the entire
> program in 'C'. when i tested the code, exactly the same problems as i
> had in Expect manifested themselves. i kept getting control codes being
> displayed to the screen. after a certain period of time the Telnet
> session reported that certain "variables" could not be set and then
> continued on its merry way.
>
> the control codes were not coming from the remote system. these are
> being passed through to the Telnet session OK. the control codes are
> being generated by the Telnet session on my local Linux box. it is
> trying to query the terminal type on the local system. but as i had
> redirected the Telnet input/output (using DUP2) to a pipe to another
> process so that i could interact with the Telnet session via software,
> the Telnet session was unable to obtain the values that it needed.
> Expect, i suspect, does exactly the same thing. i conclude this only
> because i am getting exactly the same "error" messages as it is.
try setting TERM=dumb or something before running the telnet
client. i'd hope that the relevant curses libraries wouldn't attempt
any fanciness with that sort of terminal..
otherwise, iirc expect creates a pty and does the whole terminal thing
itself (i've never actually used expect, so i could be completely
wrong here). if the other end is expecting something cleverer than a
simple linear stream of bytes for output, then you may find yourself
having to mess with ptys yourself.
(i presume you're running the telnet client executable and messing
with stdin/stdout? you could even dump that and just talk to the
network port yourself; the telnet protocol isn't too complicated if
you don't want any of the features. of course, perl has a
Net::Telnet, which would make all of this easy ;)
--
- Gus