From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96076331021306.tru64-unix-managers.marc@archive.invalid> From: kthomas () dilbert ! sysoff ! ctstateu ! edu (Karen T ! Thomas Connecticut State Universit Date: Mon, 15 Apr 1996 20:14:35 +0000 To: tru64-unix-managers Subject: SUMMARY: printing escape codes X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96076331021306 I originally asked: > I am porting people from a VMS environment where they have access > to a DCL command procedure to print to their local printer when telneting > in over a modem. The procedure prints to sys$output escape codes, then types > the file. This works great on VMS but want to know how to implement this > same procedure on DU? Does anyone know the best way for a user to print > a file to a printer directly attached to their PC when they are telneting > in from home? Here were the **many** different ways to do it. ( I used the perl script - Thanks Paul!) Paul A Sand : I've written the following Perl script for our users (stealing the idea from the Lynx C source code, so no claims to brilliance here...). I use it while telnetting in from home myself... ---snip--- #!/usr/bin/perl # # lpansi -- allows printing of files (or stdin) from ``any VT100 # or ANSI''. Based on a C program in the lynx distribution # by ``Gary Day, 11/30/93''. Saith Gary, # # Hey, it doesn't have to be complicated to be useful. # # ... and he's quite correct. # print "\033[5i"; while (<>) { print; if (eof) { # formfeed after each file print "\n\f"; } } print "\033[4i"; ---snip--- One can use this program as % lpansi file... or % prog | lpansi ----------------------------------------------------------------------------- Other responses that I didn't use but were helpful for future: (Thanks!) ----------------------------------------------------------------------------- Jon Trulson : - ----- #!/bin/ksh # print out all files to local printer # PSTART="\033[5i" # the \033 is octal for the ESC char PSTOP="\033[4i" echo $PSTART cat $* # output all files in the cmd line echo $PSTOP exit -------------------------------------------------------------- Thomas Erskine : ESC="^["; export ESC # get a real escape character in there FF="^L"; export FF # get a real form-feed character there echo -n "${ESC}[5i" cat file echo "${FF}${ESC}[4i" ---------------------------------------------------------------- "Eric Wyn Jones (01248-382407)" : Hi Karen - if you have a C compiler then this might do the trick for you ... Compile with cc -o pcprint pcprint.c then pcprint filename ============================================================================ cut here ============================================================================ #include #include main(int argc, char **argv) { int status; char on[6]={27,'[','5','i','',0}; char off[5]={27,'[','4','i',0}; FILE *pf=NULL; char ch; if (argc < 2) { printf("Usage : pcprint "); exit(1); }; if ((pf=fopen(argv[1],"r"))==NULL) { fprintf(stderr,"pcprint: Can't open file %s\n",argv[1]); perror("pcprint"); exit(1); } status=fputs(on,stdout); if (status == EOF) { fprintf(stderr,"pcprint: Error while turning printer on"); perror("pcprint"); exit(1); } while ((ch=fgetc(pf))!=EOF) { putc(ch,stdout); } /* end while */ status=fputs(off,stdout); if (status == EOF) { fprintf(stderr,"pcprint: Error while turning printer off"); perror("pcprint"); } fclose(pf); exit(0); } ----------------------------------------------------------------- "USA::US0A20::CJS35102" : #!/bin/sh echo "\033[5i" cat $1 echo "\f\033[4i" (Add the "\c" to the end of the [5i to prevent the extra line from being added. ------------------------------------------------------------------- mperlman@parsec.com (Mark Perlman): > $ write sys$output esc, "[5i" <--- How would I do this in DU? # Type the following: echo "v[5i" # this will do the trick! # What will actually be displayed will look like this: echo " Included message follows... ------------------------------------------------------------------- rwa@cs.athabascau.ca (Ross Alexander): > $ esc [0,7] = 27 <--- How would I do this in DU? in /bin/sh, from the keyboard: esc='^V^]' (that's control-v esc) >From inside a script, you don't need the ^V. > $ write sys$output esc, "[5i" <--- How would I do this in DU? echo ${esc}"[5i" (no spaces) ----------------------------------------------------------------------- -