SUMMARY: Attached-to-ANSI Printing on SS5

From: David J. Nelson (
Date: Wed Mar 22 1995 - 02:05:34 CST

> I'm using Pine 3.90 on an SS5 server running SunOS 4.1.3_U1. If I want
> to print something out from pine, it gives me the option to print to
> attached-to-ansi. If I select this, it will print out on an LPT1 port.
> Is there a shell (Perl, or whatever) script that is available somewhere
> that I can use in place of lp that will direct printing to the LPT1 port
> of a client PC using VT220 terminal emulation??

There are a series of escape sequences that you can use in VT100/220
emulation that will reroute characters from standard output destined for
the screen to the printer. To reroute characters to the printer, you use
<ESC>5i -- to send characters back to the screen again, you use <ESC>4i.

I compiled a C program sent to me from Daniel Bidwell that we are using
in lieu of lp services for all our end users. I have enclosed the source
code of that program below.

Thanks to Ken Rice <>,
          Laurel Arthur <>,
          Henry Unger <>, and
          Daniel R Bidwell <>.

| David J. Nelson | |
| Gopher and CSO Administration | |
| Office of Information and Technology | Merging onto the Information |
| Muhlenberg College - Allentown, PA | Superhighway in a Studebaker. |
| Internet: | |
| Telephone: (610) 821-3460 | |

----- cut here -----
#include <stdio.h>

#define BUFSIZE 1000000
#define OPEN_PRINTER printf("\033[5i");
#define CLOSE_PRINTER printf("\f\033[4i");

int main(int argc, char **argv){

 * We had a problem compiling the function declaration this way. If your
 * compiler doesn't like this, you might try redeclaring it as:
 * int main (argc, argv)
 * int argc;
 * char **argv; {

    char buffer[BUFSIZE];
    int i;
    FILE *fp;

    if(argc == 1){
        while(gets(buffer) != NULL){

    }else if(argc > 1){


            if((fp=fopen(argv[i],"r")) == NULL){
                fprintf(stderr,"Error reading %s\n",argv[i]);
                while(fgets(buffer,BUFSIZE,fp) != NULL){

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:19 CDT