Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
telnet, expect and the web

Posted by pentafive (pentafive), 11 July 2007
I have a expect script that telnets to a host and runs a commands and exits. The expect script is called from a KSH cgi script and then displayed to the user via a webpage.

The script works great when called from a shell script but when called from the webserver the spawned telnet session has a problem with the screen size and thus my output is littered with "Press any key to continue (Q to quit)".

I tried to use log_user 0/1 in the expect script to control what out is sent to the user and that works when it is called from CLI but over the web I get NO output at all so i am not using them at the moment.

Any ideas?


Posted by admin (Graham Ellis), 11 July 2007
I would be tempted to play with the TERM and TERMCAP environment variables to make the web one look more like the CLI one.

Posted by pentafive (pentafive), 11 July 2007
Thanks for the quick reply. I did play some with TERM but after your post I did some more.

I tried to use the following:
set env(TERM) "cons25w"
set env(TERMCAP) {cons25w|ansiw|ansi80x25-raw:\

I checked to make sure telnet recieved the new env setting with the following expect script.

spawn telnet
expect >
send -- "env list\r"
expect >
send -- "quit"

And it listed the TERM and TERMCAP env. still did not fix the web problem.

Gonna do some more playing around but wanted to post that..

Ohh I also tried vt100 and a few other termcaps.


Posted by admin (Graham Ellis), 11 July 2007
Hmmm .... it is possible for applications to check whether or not they're running from an interactive shell and perhaps yours is doing so;  as an intermediate research step, see what happens when you run you command line interface version with input and output redirects from and to files.

Posted by pentafive (pentafive), 11 July 2007
ok I will do that next.

I can now reproduce this in the shell by calling the telnet app with "-nottycopy"

eval spawn -nottycopy telnet $ip


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho