A number of solutions exist for printing from the Sun. These can be divided into application-specific solutions, Solaris 7 specific, and "classic" Unix solutions.
Unless the SAS administrator sets up a default printer for the SAS software, each user will have to set up his own printer(s). One sets up a new printer for SAS by following these steps in the X interface of SAS:
/usr/ucb/lpr -P
name_of_printer_queue in the command box and
click Next
A list of available printer queues can be found in the file
/etc/printcap
on most Unix systems or
/etc/printers.conf
on Solaris.
Applications that are capable of outputting to Postscript files can
print using another method. One prints to a Postscript file and then
prints the file using the classic Unix command lpr(1)
described below.
Text-layout applications like LaTeX use this method by preference.
Solaris 7 offers a number of printing utilities described in the
mp(1)
man page. The mp(1)
filters convert various
input file types to Postscript and output the results to the printer.
The results typically include default headers and other formatting
that are often useful, but inflexible. If you are just printing
program listings or a bit of information, the command filep
filename.txt
will give the desired result 90% of the time. See
man filep
or man -s 1 mp
for more information about
available printing filters.
Another useful tool supplied with Solaris is postprint(1)
.
This program translates ordinary text files into Postscript files,
ready for printing. Since it is a filter program (a program
that takes something on standard input, modifies it, and outputs it on
standard output), the output must be redirected either to a file or
"piped" to the lpr(1)
program (see below).
To redirect the output of into a file for later printing, go:
postprint text_file.txt > postscript_file.ps
To print directly to a Postscript-capable printer via a pipe, go:
postprint text_file.txt | lpr -Pprinter_queue_name
The "classic" Unix command for printing is lpr(1)
(or
lp(1)
, on some systems). Two commonly used options of
lpr(1)
are -P
and -h
.
-P
printer_queue_name specifies which printer the
output will go to. Users concerned about excess paper usage may use
-h
to prevent the header page from being printed.
Unfortunately, the default printer of the STAT SAS server, the HP8000
laser printer in room 5.006, is set up for printing from Windows and
MS-DOS. Text files from these systems delimit each line with a CRLF
(carriage return + line feed) sequence while Unix files only use LF to
delimit lines. If one tries to print a simple text file with the
command lpr filename.txt
, the result will be text printed
with a "stair-case" effect.
The solution is to pass the text file through a LF-to-CRLF filter
before piping it to the lpr(1)
command. In addition, one
might wish to add margins, headers, and footers to each page. This is
accomplished with the pr(1)
command. The final command is
cat filename.txt | pr | crlf | lpr
. One can create a
function in bash(1)
to accomplish the same thing with less
typing. After defining the following function,
function print { cat $@ | pr | crlf | lpr }
...all one need do is type print filename.txt
. To define this
function, just type it in on the bash(1)
command line, or put it in a
script file that gets executed each time you logon, such as
~/.bashrc
or a file like ~/aliases
.
In addition to the CRLF problem, HP printers use the HP Roman
character set by default. This character set is not the same for
accented characters as the ISO-8859-1 character set used by Solaris.
This means that additional character translation is needed if one
wishes to print text files containing accented characters. This
translation is accomplished using the recode(1)
program in
the following script:
Type set
at the bash(1)
command line to see which
version of print has been defined for you.