Old Skool Printing via Terminal

JamesBowen

19+ years progress programming and still learning.
HI

We have a working process which enables us to print from linux back thought a PuTTY terminal and it's done using a PHP script. So I tried to duplicate the code into OE and I came up with the following code. However it does not work quite right. Why?

Code:
DEFINE STREAM sTerminal.
DEFINE VARIABLE cSimpleText AS CHARACTER   NO-UNDO.

cSimpleText = 'This should come out of the printer.'.

OUTPUT STREAM sTerminal TO TERMINAL PAGED.

PUT STREAM sTerminal CONTROL CHR(27) + '[5i'.
PUT STREAM sTerminal UNFORMATTED cSimpleText.
PUT STREAM sTerminal CONTROL CHR(27) + '[4i'.

OUTPUT STREAM sTerminal CLOSE.
The output onto paper comes out like this:

22;1H21;1HThis21;6Hshould21;13Hcome21;18Hout21;22Hof21;25Hthe21;29H printer.22;
 
It looks to me like you are getting the cursor positioning commands in the output stream, which probably comes from output to TERMINAL. Have you tried getting the ID of the pseudo-terminal and outputting directly to that device?
 
It worked by changing TERMINAL to "/dev/pts/3". Thanks. Does this mean I could to a print of the current screen?
 
Print screen, other than via Windows functionality, is a tricky thing since, unlike standard, non-Ajax browser screens, they are painted a piece at a time, not refreshed as a whole ... even when they are actually being refreshed as a whole, if you get what I mean. Years ago, there were some products that would sit on the connection and allow a screen print and there have been some discussions recently about the concept, but it certainly isn't a standard simple option that is always there ... unless you use the Windows functionality.
 
OK quick change to the code and now I've got a new problem the print job is now being truncated when sent back through PuTTY. My Source PCL File is 158,299 and the target print file is 139,264.

Why would my print job kept getting truncated?

P.S. I am using a cool little tool called miniraw.exe which captures the print job from PuTTY.

Code:
DEFINE STREAM sTerminal.
DEFINE VARIABLE cSimpleText AS CHARACTER   NO-UNDO.
define var mData as memptr.

Set-size(mData) = 0.
copy-lob from file '/tmp/ChangeOfAddress_89_0_0.pcl' to object mData.

OUTPUT STREAM sTerminal TO '/dev/pts/4' Binary no-echo no-convert.

PUT STREAM sTerminal CONTROL CHR(27) + '[5i'.

export stream sTerminal mData.

PUT STREAM sTerminal CONTROL CHR(27) + '[4i'.

OUTPUT STREAM sTerminal CLOSE.

message get-size(mData).

Set-size(mData) = 0.
 
One common cause for such things is no handshaking ... how consistent is it? There might also be a character sequence in the output which is being read as an end of file.
 
Problem solved.

Had to stty -onlcr command was needed to translate newline to carriage return-newline return new-line before sending the print job to the terminal.

Sorted.
 
Back
Top