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?

-Jonathan

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:
Code:
set env(TERM) "cons25w"
set env(TERMCAP) {cons25w|ansiw|ansi80x25-raw:\
       :am:bs:NP:ms:pt:AX:eo:bw:ut:km:\
       :co#80:li#25:pa#64:Co#8:it#8:\
       :al=\E[L:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:\
       :dc=\E[P:dl=\E[M:do=\E[B:bt=\E[Z:ho=\E[H:ic=\E[@:cb=\E[1K:\
       :nd=\E[C:rs=\Ec:so=\E[7m:se=\E[27m:up=\E[A:cr=^M:ta=^I:\
       :AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:sc=\E7:rc=\E8:\
       :k1=\E[M:k2=\E[N:k3=\E[O:k4=\E[P:k5=\E[Q:k6=\E[R:k7=\E[S:k8=\E[T:\
       :k9=\E[U:k;=\E[V:F1=\E[W:F2=\E[X:K2=\E[E:nw=\E[E:ec=\E[%dX:\
       :kb=^H:kh=\E[H:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:le=^H:sf=\E[S:sr=\E[T:\
       :kN=\E[G:kP=\E[I:@7=\E[F:kI=\E[L:kD=\177:kB=\E[Z:\
       :IC=\E[%d@:DC=\E[%dP:SF=\E[%dS:SR=\E[%dT:AL=\E[%dL:DL=\E[%dM:\
       :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:cv=\E[%i%dd:ch=\E[%i%d`:\
       :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:bl=^G:\
       :ve=\E[=S:vi=\E[=1S:vs=\E[=2S:
}


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

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


And it listed the TERM and TERMCAP env. BUT...it 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.


-Jonathan

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"

Code:
eval spawn -nottycopy telnet $ip


-Jonathan



This page is a thread posted to the opentalk forum at www.opentalk.org.uk 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., 2021: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho