From 5dc602d16c5be2fd035b254ca23484a90aebd6dc Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 9 Jan 2006 00:45:48 +0000 Subject: doc 5 git-svn-id: svn://tug.org/texlive/trunk@81 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/texsis/base/letr | 230 +++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100755 Master/texmf-dist/doc/texsis/base/letr (limited to 'Master/texmf-dist/doc/texsis/base/letr') diff --git a/Master/texmf-dist/doc/texsis/base/letr b/Master/texmf-dist/doc/texsis/base/letr new file mode 100755 index 00000000000..ad4697fc80e --- /dev/null +++ b/Master/texmf-dist/doc/texsis/base/letr @@ -0,0 +1,230 @@ +#!/bin/sh +# +# letr - a Unix shell script for printing a letter with an addressed +# envelope, using TeXsis (the TeX macros for physicists). The syntax is: +# +# letr [ -q ][ -Pprinter ] [ dvips flags ] [ filename ] +# +# where "filename" is the name for your TeX job. The TeX instructions +# for creating your letter will be put in the file filename.tex, while +# the instructions for creating the printed envelope will be in the +# file filename.env. If no name is given the default is "TeXletter". +# +# You first edit your letter with your default EDITOR, then it is run +# through TeXsis. You can preview the letter, and then choose whether +# or not to print it, and whether or not to print the addressed envelope. +# +# Use the -q flag to bypass the editor, and -P to specify an alternate +# printer. All other flags are passed to dvips. So, for example, if +# you give the -m flag it will go to dvips and the letter (not just the +# envelope) will be printed in manual feed mode, so you can put your own +# paper in the printer for it. +# +# To get the envelope to print in landscape mode and with manual feed +# we call dvips explicitly. If you need to, change the DVIPS command +# and ENVFLAGS below to match your local site configuration. +# +# Eric Myers - 27 January 1996 +# Department of Physics, University of Michigan, Ann Arbor +# @(#) $Id: letr,v 1.7 2000/06/01 20:02:30 myers Exp $ +###################################################################### +# Local Customization: + +EDITOR=${EDITOR-"emacs"} # editor (default to emacs) +DVIVIEW=${DVIVIEW-"xdvi"} # dvi file viewer (dviview is more general) +DVIPS=${DVIPS-"dvips -q"} # general dvips command +ENVLFLAGS="-m -t landscape" # dvips flags for the envelope + +#====================(end of customization)====================* + +## Parse command line arguments. Unrecognized ones are saved for dvips + +FNAME=${FNAME-"TeXletter"} # name of file to process +FLAGS=" " # flags to pass on to dvips +NOEDIT="" + +while [ $# != 0 ] +do case "$1" in + -P*) PRINTER=`echo $1 | tail +3c` # strip off the -P + LPDEST=$PRINTER ;; + -q) NOEDIT="NOEDIT" ;; + -*) FLAGS="$FLAGS $1" ;; + *) FNAME="$1" ;; + esac + shift +done + +PROG=`basename $0` + +############### +# Determine which printer we shall use, and how. In NeXTStep the lpr +# command ignores the $PRINTER variable, so we will correct for that +# here by always using `lpr -P$PRINTER`, with "Local_Printer" as the +# default. For other Unix change default printer to 'lp'. For SYSV +# we need to use "lp -d$LPDEST" instead. + +if [ -x /usr/ucb/lpr ]; then + if [ -x /sdmach ]; then # NeXTStep + PRINTER=${PRINTER-"Local_Printer"} + else # other BSD + PRINTER=${PRINTER-"lp"} + fi + # The -h option suppresses the banner page + LPR="/usr/ucb/lpr -h -P$PRINTER" +fi + +if [ -x /usr/bin/lpr ]; then # BSD (Linux, Solaris) + PRINTER=${PRINTER-"lp"} + # The -h option suppresses the banner page + LPR="/usr/bin/lpr -h -P$PRINTER" +fi + +if [ -x /usr/bin/lp ]; then # SYSV (eg. HP-UX) + LPDEST=${LPDEST-"lp"} + # The -onb option suppresses the banner page on HP LaserJet3/4 (and 5?) + LPR="/usr/bin/lp -onb -d${LPDEST} " +fi + +if [ ! $?LPR ]; then + echo "Cannot determine lpr/lp command." + exit 2 +fi + +## Figure out line end suppression for BSD or SYSV + +if [ "`echo 'EC\c'; echo HO`" = "ECHO" ]; then + SYSVNL="\c"; BSDNL="" # System V line control +else + BSDNL="-n"; SYSVNL="" # BSD line control +fi + +## the function `ask_def default text` asks a question and returns +## the user's answer, using the default if just is pressed. + +ask_def () { + DEFAULT=$1 ; shift + echo ${BSDNL} "$* [${DEFAULT}] ${SYSVNL}" + read ANS + if [ -z "$ANS" ]; then ANS=$DEFAULT ; fi + export ANS; } + + +## Strip off .tex from the filename, if it is included. +## Any trailing . is also removed (helps for tcsh filename completion). + +FNAME=`basename $FNAME .tex` # get just the file name, strip .tex +FNAME=`basename $FNAME .` # get just the file name, strip "." + +## If the named TeX file does not exist, create it with a simple +## TeXsis \letter template + +if [ ! -f ${FNAME}.tex ]; then +cat >${FNAME}.tex </dev/null 2>&1 + sleep 1 ;; + esac + + echo " " + echo "Default printer is '${PRINTER}'." + ask_def yes "Do you want to print this now? " + case $ANS in + yes|Y|y|YES|Yes) + ${DVIPS} ${FLAGS} ${FNAME}.dvi # >/dev/null 2>&1 + echo "Printing the letter..." + ${LPR} ${FNAME}.ps ;; + *);; + esac + +fi + + +## Process envelope, if desired and it exists + +if [ -f ${FNAME}.env ]; then + + ask_def yes "Do you want to print the envelope? " + case $ANS in + yes|Y|y|YES|Yes) + /bin/rm -rf ${FNAME}.dvi ${FNAME}.ps + texsis ${FNAME}.env + $DVIPS ${FLAGS} ${ENVLFLAGS} ${FNAME}.dvi ## >/dev/null 2>&1 + echo "Printing the envelope... Please feed the printer. " + ${LPR} ${FNAME}.ps + esac + +else + echo "No envelope file ${FNAME}.env was found." +fi + +# Clean up: remove .dvi file, .ps file, and .log file (but keep .env file). + +/bin/rm -f ${FNAME}.dvi ${FNAME}.log ${FNAME}.ps + +exit 0 -- cgit v1.2.3