* SUMMARY: printing escape codes
@ 1996-04-15 20:14 kthomas
0 siblings, 0 replies; only message in thread
From: kthomas @ 1996-04-15 20:14 UTC (permalink / raw)
To: tru64-unix-managers
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 <pas@unh.edu>:
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 <trulsonj@mscd.edu>:
- -----
#!/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 <tom@silverlock.dgim.doc.ca>:
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)" <e.w.jones@bangor.ac.uk>:
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 <stdio.h>
#include <stdlib.h>
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 <file>");
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" <CJS35102%USA.US0A20.decnet@usav01.glaxo.com>:
#!/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 "<CTRL>v<ESC>[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)
-----------------------------------------------------------------------
-
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-04-15 20:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-04-15 20:14 SUMMARY: printing escape codes kthomas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox