Printing at Canisius

=============================================================================
Overview:  Printing is very specialized to each UNIX site, and this module
           gives very specific information as to how to print files at 
           Canisius College.
=============================================================================

Section                            Topics
-------                            ------

   Standard UNIX print commands
   Printing Non-text files
   Printing scripts
   Monitoring printouts
   Cancelling printouts
   The multiprint program
   The cleanscript program




Standard UNIX print commands
----------------------------

     The basic UNIX command to print is "lpr" from an ancient form "line
print".  Here is the format:

    lpr -P[name] file1 file2 ...

The name is a short acronym for the printer you want.  Here are the ones 
currently available:

      hlpj  -- Hewlett Packard Laserjet in WTC 206
      qms   -- the big QMS printer in WTC 206
      qmsl  -- landscape on the QMS printer, same machine, only the paper
               comes out "lengthwise" for wider files
      ps    -- Postscript on the QMS, same printer, but use this if you have
               a file in Postscript form (not regular text)
      sp    -- Sparc Printer in WTC 208  (this accepts regular text files
               as well as postscript files)
      library -- Hewlett Packard Laserjet in Library lab

Several of these commands allow you to select the font and many other options.
To go through the questions to select these fonts, use the -i option ONLY.
The commands that you can do this with are hplj and sp:

      hplj -i
      sp -i


Printing Non-text files
-----------------------

    DON'T DO IT!  Please don't print files like a.out or anything that ends in 
.o.  Binary and non-text files usually cause the printer to screw up and waste 
an enormous amount of paper printing garbage characters.

    If you are unsure of what your file contains, try looking at it with vi
first.  Or use the UNIX file command: 

     % file a.out

If it says English, commands, or text, you can print it.  But if
it says "executable" anywhere, then don't.

     Also please pick your printouts up promptly.  Do not leave them laying 
around as someone may throw them away or someone else could pick up your 
assignment and copy it.  There are recycle bins in the rooms next to the 
printers for all the printouts that you don't want to keep.  Please save trees 
and be an environmentally good citizen!


Printing scripts
----------------

     When you use "lpr" to print a file on either the Sparc or QMS printers,
the output is put right up against the right margin, making it impossible
to staple or punch holes in papers.  There are two special shell scripts here
at Canisius that make printing a bit easier by shoving the image to the right 
on the page.  These scripts can be used just like regular UNIX commands, and
they are:

     sp   -- print a file on the Sparc printer
     qms  -- print a file on the QMS printer

Just give the name of the file after the command.  You can also print more
than one file.  Each will have its own identifying banner page so that you
can separate them easily:

     % sp myfile
     % sp *.c

The latter example prints all C program files in the current working directory.
The qms command works the same way.

     A more general command is "printfile".  It presents a menu and allows you
to print a regular file in either normal or landscape form.  Landscape refers
to printing so that the text runs across the wide part of the page, rather
than across the narrow part like a normal book.  To use, just type:

     % printfile

     You can also print out man pages using printfile, and compress printouts
so that either 2, 4 or 8 pages from your file are printed on a single piece
of paper.

     These shell scripts do not exist at other colleges, although they may
have their own.  You can look at the actual scripts, since they are written in
Cshell language and can be found in the directory /usr1/local/bin.


Monitoring printouts
--------------------

     Once you send a file to a printer, it waits in the UNIX system until the
printer is ready to accept it.  If the printer is busy, the file may wait for a
bit.  You can check on the progress of your printouts by using "lpq"
which stands for "line printer query".  Specify the printer using the short 
names presented above.

     % lpq -Psp

This asks what the status of "sp" or Sparc printer is.  Here's a sample:

     sp is ready and printing
     Rank   Owner      Job  Files                                 Total Size
     active meyer      386  syllabus                              5039 bytes
     1st    msmith     387  project1.c                           38532 bytes
     2nd    fleckens   389  zzzout                              105362 bytes

The job numbers are the important things to remember when you want to control
your print jobs.


Cancelling printouts
--------------------

     You can cancel print jobs as long as they are still in the UNIX system.
As long as they show up on the lpq output, they can be cancelled.  But once the
printout has disappeared from the UNIX queue, it is in the memory of the 
printer, and UNIX can no longer access it.  In fact, if something goes wrong
and the printout needs to be killed, you have to turn off the printer.  Modern
printers have a huge amount of memory and can generally hold entire files
while they are printing them.

    If you are the owner of a printout, you can kill it by removing it from
the queue.  Once again, here's the output of lpq:

     Rank   Owner      Job  Files                                 Total Size
     active meyer      386  syllabus                              5039 bytes

The owner is listed, along with whether the job is currently printing (active)
or not.  Use the job number on the lprm (line printer remove) command to 
cancel it:

     % lprm -Psp 386


The multiprint program
----------------------

     Another nifty program developed here at Canisius is multiprint.  It is
actually a C program, not a shell script, and you can view its source code
in /usr1/local/src/multiprint.c.  (One of the best ways to become a talented
programmer is to read others' code.)

     Multiprint formats one or more files so that they will print easily.  It
inserts headers and footers, page numbers, line breaks and other features.
But it is very easy to use, unlike the nroff program.

     You can give multiprint the information it needs to work either on the
command line using options, or interactively.  To specify interactive use,
do the following:

     % multiprint -interactive

It will prompt you for every option, including a list of file names.

     The command line option method is easier to use if you only have a few
options.  You can see what the options are by typing the multiprint command 
without anything:

     % multiprint

It will not format any files, but rather print out all the options and quit.

     The simplest way to use multiprint is just to give it a list of input
files that you want formatted:
 
     % multiprint mypaper

or if you have a bunch of C programs in a directory and you want one big
printout:

     % multiprint *.c

Each file starts on a new page, but the line numbers are continuous.  This
"easy" form of multiprint puts a header and a footer on every page.  The
header and footer are both set off from the text with lines of dashes, and
there are 66 lines per page, which is suitable for the QMS printer.  Page
numbers are inserted, the date and time in the upper left corner, and the
name of each file as it is printed.  The output file is called "zzzout" and
that is the file you should send to the printer.

     Finally, if you need more control over the options, but you don't want
to go through the long interactive series of questions, use the options.
Here's an example.  It formats a book, consisting of files called chap.1,
chap.2, chap.3, etc.

     % multiprint -i chap.* -o mybook -lpp 55 -pagestyle 3 \
         -botcenter %p -topright %f -topleft "The Story of my Life"

The input file names follow the -i option.  All other options can have only
one value after the option flag.  For example, you can specify only one
output file, using the -o flag.  The lines per page is changed to 55 by
using -lpp and a different page number style is chosen.  This style would
print out "page 17" for page 17.  (All the styles are shown when you just
type multiprint to see the list of options.)

     There are three areas in the footer and three in the header.  These are
called -botleft, -botcenter, -botright, -topleft, -topcenter and -topright.
Each area can be given a literal value, such as -topleft above.  If this
character string contains blanks, it must be surrounded by blanks as shown.
There are three special codes that can be used in these fields.  When a code
is encountered it is substituted with an appropriate character string:

     %f    --   the name of the currently printing file
     %p    --   the current page number
     %d    --   the date and time when multiprint started

The date and time does NOT change from page to page, although obviously the
page number does.  If you are printing more than one file, then each page
that belongs to a certain file has that file's name.

     There are a few other options, such as -sp which lets you change the
starting page number.  -ls changes the line spacing so that you can double
or triple space the printout.  -number puts line numbers along the left hand
side, and is used mostly for programs so that you can refer to line numbers 
easily.

     In conclusion, multiprint does a minimal amount of paginating and
formatting using simple options.  It is not a word processor, but its options
are much simpler than nroff's.


The cleanscript program
-----------------------

     Sometimes you want to capture what is on your screen into a file so that
you can later have a paper record or even insert part of the interaction into
a document.  There is a standard UNIX command called "script" which does this.
To use it, just type

     % script

UNIX responds with

     script started, file is typescript

and gives you a shell prompt.  From this point on, whatever you see on your
screen, and whatever you type on the keyboard, will be copied into the file
"typescript".  To get out of this, either press CONTROL-D or type the
command:

     % exit

(Technically what script does is to start up a new shell.  Exit or CONTROL-D
kill the currently running shell.)

     After you've ended the script, the file "typescript" is yours to edit
or view or use in any way.  However, UNIX puts EVERYTHING into it, including
backspaces and return characters.  The result is messy.  Cleanscript to the 
rescue!  If you type:

     % cleanscript

it will clean the file "typescript" in the current directory.  You can also
use it with redirection to clean a specific file.