Up March/05
Printing on Linux is accomplished with the most wildly complicated set of utilities imaginable. And -- no matter what else -- it will assume you have an inkjet or laser printer, and want everything in Postscript format.
I don't. I have a dot-matrix printer which will probably last another 100 years, and I print nearly everything in plain text format. The information below shows variously how to make some changes to allow printing directly to an LPT port (device PRN: in DOS), how to shift all the printing to a Windows box (much better utilities) via SAMBA, and how to change some file formats to plain text -- including pdf.
It is just a matter of using 'cat' to send a file to 'lp0', Keep this in /usr/local/bin/ and make it executable by all.
#!/bin/sh
# /usr/local/bin/print
# 9/99 script for printing from console
[ "x$1" = "x" ] && {
echo "Usage: print {file}";
exit;
}
cat $1 > /dev/lp0
To print a local file type 'print {filename}'
This information can be incorporated directly into Lynx and Pine.
For Pine it requires the following lines in the systemwide '/etc/pine.conf'file ...
# Your default printer selection
printer=/usr/local/bin/print -
# List of special print commands
personal-print-command=
# Which category default print command is in
personal-print-category=3
For Lynx the following line is required in the systemwide /etc/lynx.cfg file ...
PRINTER:use Local Printer:cat %s | /usr/local/bin/print - :TRUE:66
Man pages are strangly formatted and can't just be printed after viewing. The following will remove all the back-strikes whcih otherwise make the file unreadable.
#!/bin/sh
# this is a pipe /usr/local/bin/printman {manpage}
# print a man page to plain text, in home directory
echo "usage: printman {manpage} > ~/{same name file}"
echo
echo ... printing manpage $1, hold on ...
man $1 | col -b > ~/$1
This just writes a file of the same name as the manpage you were looking at. For example, if you typed 'man ls' to get information on 'ls', then 'printman ls' will write the file 'ls' in your home directory. To print this file type 'print ls'.
If 'pdftotext' is available, the following can be used to print a pdf file after conversion to html
#! /bin/sh
# /usr/local/bin/printpdf, cleanup of pdf file, HTML-ize, and print
pdftotext -raw $1 foo
cat foo | sed -e 's/[[:cntrl:]]//g' | sed -e 's/^[[:space:]]*$//' \
| sed -e '/^ *[[:digit:]*] *$/d' \
| sed -e 's/-$//g' \
| fold -s \
| sed -e 's/^$/<P>/' \
| uniq > $1.htm
lynx -dump $1.htm | print -
rm -f foo
The SAMBA suit of files allows networked communication with Windows machines. I use a Windows 3.11 computer without a monitor or keyboard to do networked printing. It is set up to print from its Epson LQ-570 dot matrix printer, and will spool 10 files. If the power goes off the computer simply reboots into operation by itself -- unlike some later Windows Operating Systems. But later Windows boxes could also be used for the same purpose.
The Windows machine has to be set up to 'export' its printer, under some name -- I use 'Epson'-- and of course be connected to the network. Below are a set of utilities and inserts into rc files to allow printing via the network.
Printing a local file uses the command 'printfile' -- which goes as follows (the remote Windows box happens to be known as 'Dragon') ...
#!/bin/sh # /usr/local/bin/printfile # 9/99 script for printing to network printer smbclient '\\Dragon\EPSON' -PNc 'print -' > /dev/null smbclient '\\Dragon\EPSON' -PNc 'print /usr/local/bin/ff' > /dev/null
The second line sends a formfeed. The file 'ff' is created by inserting a '0Ch' -- a formfeed -- into 'ff'.
Do that with with 'cat > ff; ^L; ^D'.
To print a local file type 'printfile {filename}'
This information can be incorporated directly into Lynx and Pine.
For Pine it requires the following lines in the systemwide '/etc/pine.conf' file ...
# Your default printer selection
printer=/usr/local/bin/printfile
# List of special print commands
personal-print-command=
# Which category default print command is in
personal-print-category=3
For Lynx the following line is required in the systemwide /etc/lynx.cfg file ...
PRINTER:use Local Printer:cat %s | /usr/local/bin/printfile:TRUE:66
Website Provider: Outflux.net, www.Outflux.net
URL:http://jnocook.net/geek/printing.htm