#!/usr/local/bin/bash # # Copyright (C) 1995, Mats Kindahl. All rights reserved. # This program is in the public domain, you can redistribute # it and/or modify it as long as this copyright notice is # kept. # # This software is delivered as-is. There is NO WARRANTY, neither # implicit nor explicit, for this code. # # E-mail: matkin@docs.uu.se # # This is a small shellscript that I use to transform a DVI-file into # a postscript booklet and print it on the printer. # # The program accepts # # -Pprinter Print booklet on printer. If printer is `-', print on # standard output. # PATH=/usr/bin/:/usr/ucb:/usr/sup/tex/bin:/usr/hacks/bin trap Cleanup EXIT # Cleanup on exit # Cleanup # Cleanup after script (remove created files). Cleanup () { rm -f /tmp/booklet$$.ps } # Usage # Print usage and exit script Usage () { echo "Usage: ${0##*/} [ -Pprinter ] infile" 1>&2 return 1 } # print # Print DVI-file in booklet style (two pages per page, booklet # sorted). print () { dvips $1 -o | psbook | psnup -pa4 -2 >/tmp/booklet$$.ps if [ "$PRINTER" = "-" ] then cat /tmp/booklet$$.ps else lpr /tmp/booklet$$.ps fi } # Process switches (getopts does not work the way I want). while [ -n "$1" ] do case "$1" in -P*) PRINTER=${1#-P} ;; --) break ;; -*) Usage ;; *) break ;; esac shift done [ -z "$1" ] && Usage print $1