Terminal initialization strings
Posted in 1993
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
The problem: I need to suppress the sending of the terminal initialization sequence from C4GL programs that send their output to standard out. The environment: Sun 4/470 running SunOS 4.1.2.1 C4GL Version 4.10.UC.2 4GL Runtime 5.0. For the sake of simplicity and ease of maintenance, many of our report programs actually collect only key data and pass it to one or two core programs which take command line parameters. The output from the core report program is sent to standard out, and is redirected at the level of the calling program. We've tried the simple case where the calling program creates and runs a shell script with the core report program on the inside, but this starts to fail when the "command line" in the shell script is longer than the csh buffer (about 2k bytes). To get around this problem, we've used the xargs command in a pipe. Note the following example: define the_pipe char(80) ... let the_pipe = " xargs -e -n16 labels.4ge -t9 -zS -O -T " ... start report print_it to pipe the_pipe foreach crsr_main into r_rec.* output to report print_it() end foreach REPORT print_it() output left margin 0 top margin 0 bottom margin 0 right margin 80 page length 1 format on every row print r_rec.addrid using "<<<<<&" end report The calling program sends the key data collected by a cursor to the labels program via output to pipe and the xargs program. Xargs gathers data values 16 at a time and hands them to the labels.4ge program. Xargs collects the output from multiple invocations of labels.4ge and passes the output out as a single stream. It works - sort of. Before every group of 16, a terminal initialization sequence is sent out in the stream. If the output is ultimately redirected to a file, we end up with control characters we don't need. Arrgghgh! If we redirect it to a file instead of pipe via xargs, we need to have all of the key data on the command line and we overflow the csh buffer again! When I called this problem into the Informix Tech Support I was told that this is beyond what they intended the "report to pipe" syntax to support, and that I was on my own. Anybody have any ideas? Thanks in advance ---------------------------------------------------------------------------- Jeff Cauhape cauhape@TWG.COM 415/962-7147 Room 226 (SneakerNet) For every complex problem, there is a solution that is simple, neat, and wrong. -- H. L. Mencken ---------------------------------------------------------------------------- PS: for the _terminally_ curious. "-e" and "-n16" are xargs arguments. The -e turns off the logical end of file character which causes xargs to recognize the closing of the pipe as the end of the input instead. The -n16 tells xargs to take the input 16 items at a time or until the supply is exhausted. The "-t9", "-zS", "-O" and "-T" are labels.4ge arguments. PSS: I've tried deleting the initialization sequence from the termcap entry. This only causes Informix to get creative. If I replace the sequence with something innocuous - like tab and return - the program bombs with an invalid termcap entry error.
In comp.databases.informix Jeff Cauhape (cauhape@twg.com) writes: >The problem: I need to suppress the sending of the terminal initialization >sequence from C4GL programs that send their output to standard out. To >get around this problem, we've used the xargs command in a pipe. > let the_pipe = " xargs -e -n16 labels.4ge -t9 -zS -O -T " > start report print_it to pipe the_pipe > > foreach crsr_main into r_rec.* > output to report print_it() > end foreach finish report print_it -- I trust! >The calling program sends the key data collected by a cursor to the >labels program via output to pipe and the xargs program. Xargs >gathers data values 16 at a time and hands them to the labels.4ge >program. Xargs collects the output from multiple invocations of >labels.4ge and passes the output out as a single stream. It works >- sort of. >Before every group of 16, a terminal initialization sequence is >sent out in the stream. If the output is ultimately redirected to >a file, we end up with control characters we don't need. Arrgghgh! I would suggest that this terminal initialization sequence is being produced by labels.4ge, and not by the example code above. One justification for this is that the labels.4ge program is run once every 16 lines, whereas the report has no parameter that is tied to the number 16. The question therefore is "What statement in labels.4ge is causing the program to enter form mode?". There are many possible answers; opening a window, PROMPT, MESSAGE, ERROR, DISPLAY AT, displaying a form, and some OPTIONS setting operations too. I haven't checked, but it would not surprise me to find that a REPORT TO SCREEN also played with form mode. >If we redirect it to a file instead of pipe via xargs, we need to >have all of the key data on the command line and we overflow the >csh buffer again! Send it to the file, and then use xargs reading from the file? >When I called this problem into the Informix Tech Support I was told >that this is beyond what they intended the "report to pipe" syntax >to support, and that I was on my own. I suspect that they support person simply hadn't understood what was going on sufficiently clearly. What you are doing is within the remit of REPORT TO PIPE, though avoiding the terminal initialization sequence is not entirely straight forward. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>