Visual COBOL 3.0 and TERM environment variable on linux

How do I get Visual COBOL runtime to accept  a blank or generic TERM environment variable?


All of our COBOL programs run on Linux with no user session (started by cron or other daemon processes).  All of these programs have stdout redirected to log files and use the "DISPLAY" statement to put info into the log files.


Most of this works fine, but in a few cases (and I cannot see anything special about the DISPLAY statements) I get a message like 


com.microfocus.cobol.program.COBOLRuntimeException: 191     Terminal type not defined [ts236h (while in native code - see cause for more information)]


There is no TERMINAL per se, so I just want the DISPLAY the string.


The last line in the log file before the error is from this source line


display 'values returned to topend: ' out-detail-tbl.


where out-detail-tbl look like.


       01  out-detail-tbl.
           05  dtl-div-nr                      pic x(3).
           05  dtl-div-name                    pic x(31).      
           05  dtl-div-ltr                     pic xx.
           05  dtl-reg-id                      pic xx.


this DISPLAY occurs in a loop which should occur 19 times, but only occurs once.


If I run the program (unchanged) from Linux logon session instead of launching it from the daemon , it works.

  • I can't guess what in your program is triggering this error. It sounds like some DISPLAYs are causing the runtime to want to send terminal-control sequences.

    A couple of things you might try:

    • Set TERM=dumb in /etc/environment (or on the command line, if the command line is interpreted by a suitable shell), so that TERM is always set to something.
    • Enable the S5 runtime switch for your program. You can do that by including "( S5)" on the command line (including the parentheses, which need to be escaped if the command line will be interpreted by the shell), or by setting COBSW= S5 in the environment. That tells the runtime to make DISPLAY UPON CONSOLE redirectable. It might have an effect on your issue.

    Note there's no such thing as a "generic" value for $TERM. The TERM environment variable was standardized by POSIX.1 and XPG3, and used by convention long before that in both the AT&T and BSD UNIX families, but none of those define behavior when TERM is unset or empty. (In fact, they don't standardize its value at all.)

    If "there is no terminal per se", then where are the DISPLAYs going?