#!/bin/bash

# simple replacement for lpr -- uses ssh
# This script does not filter, so only use it to "lpr" PostScript
# files.  (use enscript for text)
# exercise for the reader: make this script use magicfilter

# an unprivileged port you don't use for anything else
LOCAL_PORT=10515

# A host that is allowed to connect to your networked printer or
# print server, and on which you have an account you can ssh to
# without being prompted for a password (see man ssh-agent)
HOST=capsicum.zgp.org

# Name of your printer or printer server
PRINTER=treekiller.sandbox.zgp.org

# How long to leave the connection up.  If this script fails for you,
# try increasing this
SLEEP=5

# Here's the fun part: we open up a port for forwarding, put ssh in
# the background as soon as it's authenticated, and sleep to give
# rlpr a chance to connect
ssh -fL ${LOCAL_PORT}:${PRINTER}:515 $HOST sleep $SLEEP && /usr/bin/rlpr --send-data-first --printhost localhost --port $LOCAL_PORT
$*

# you might not have to use --send-data-first, but we had to for
# an older Hewlett-Packard LaserJet.

# This last line makes sure the script does not exit until LOCAL_PORT
# is available to use again

sleep $SLEEP

========= SNIP HERE

-----

%~
Capture Those Errors
%%~

(Thanks to the GAR project:
http://www.lnx-bbc.org/README.html for the tip.)

If you have a lengthy command-line task, such as building complicated
software, and need to catch an error that whizzes by in the middle,
use script. It will run a shell and log all input and output to a file
called "typescript" that you can then search or submit with a bug
report.


------


%~
Dave's Not Here
%~

The vacation program lets you send an automatic message when you'll be
away from your e-mail. You can see who received your message with
