Date: Sun, 24 Aug 2014 16:53:42 -0700 From: Martin Alejandro Paredes Sanchez <mapsware@prodigy.net.mx> To: Beeblebrox <zaphod@berentweb.com>, freebsd-questions@freebsd.org Subject: Re: printcap configuration problem (if-MAPS 2/4) Message-ID: <20140824165342.7e3443b0@morena.maps.net> In-Reply-To: <20140819090205.111cba9a@rsbsd.rsb> References: <1405676044178-5929730.post@n5.nabble.com> <alpine.BSF.2.11.1407180554080.77290@wonkity.com> <53C919E0.6070008@bananmonarki.se> <alpine.BSF.2.11.1407180725500.77290@wonkity.com> <20140718183958.1864052a@rsbsd.rsb> <20140727221419.35efb9b0@morena.maps.net> <1406966714419-5934110.post@n5.nabble.com> <1406986762673-5934162.post@n5.nabble.com> <alpine.BSF.2.11.1408021027580.67716@wonkity.com> <20140803083513.47e21f3b@rsbsd.rsb> <20140807225729.69db80ef@morena.maps.net> <20140819090205.111cba9a@rsbsd.rsb>
next in thread | previous in thread | raw e-mail | index | archive | help
Create the file /usr/local/bin/if-MAPS In its content, put the following #!/bin/sh # # This shell espect to be a text filter (filt.input=3Dif capability in # /etc/printcap) confusingly called the input filter. # # When LPD starts this filter program. It sets: # # standard input to the file to print # standard output to the printer device (tty.device=3Dlp capability) # standard error append to the error logging file (spool.log=3Dlf capabil= ity) # current directory to the spooling directory (spool.dir=3Dsd capability) # =A0 uid=3D1(daemon) gid=3D1(daemon) # # With the following parameters: # # filter-name [-c] -wWidth -lLength -iIndent -n login -h host acct-file # # -c appears if job submitted with "lpr -l" (print control # characters and suppresses page breaks) (raw printing) # width is the page width (page.width=3Dpw capability), default 132 # length is the page length (page.length=3Dpl capability), default 66 # indent is the amount of the indentation from "lpr -i", default 0 # login is the account name of the user printing the file # host is the host name from which the job was submitted # acct-file is the name of the accounting file (acct.file=3Daf capabilit= y) # # This filter should exit with the following exit status: # # exit 0 If the filter printed the file successfully. # exit 1 If the filter failed to print the file but wants LPD to try # to print the file again. LPD will restart a filter if it # exits with this status. # exit 2 If the filter failed to print the file and does not want LPD # to try again. LPD will throw out the file. # # You need the following packages installed # # GhostScript ghostscript-gpl GPL Postscript interpreter # psUtils psutils-letter Utilities for manipulating PostScript documen= ts # Enscript enscript-letter ASCII to PostScript filter # # If user removes the job, LPD will send SIGINT (SIGNAL INTERRUPT) # so trap SIGINT (and a few other signals) to clean up after ourselves. # # 1 HUP (hang up) # 2 INT (interrupt) # 15 TERM (software termination signal) # trap 'LogError 2 "Signal HUP traped"' 1 trap 'LogError 2 "Signal INT traped"' 2 trap 'LogError 2 "Signal TERM traped"' 15 umask -S u=3Drwx,g=3Drwx,o=3D FilterName=3D`/usr/bin/basename "$0"` PATH=3D/bin:/usr/bin:/usr/local/bin TMPDIR=3D`/usr/bin/mktemp -q -d "/var/tmp/$FilterName.XXXXXX"` || ErrorTmpD= ir export TEMP=3D"$TMPDIR" TMPDIR PATH [ -n "$TMPDIR" -a -d "$TMPDIR" ] && /usr/bin/chgrp daemon "$TMPDIR" # # SendMailLog: Send the logs by mail (sendmail). # SendMailLog() { LogTrace "Sending logs by mail (this mail)" { echo "To: $User@$Host" [ -e "$TMPDIR/ErrorFile" ] && echo "Cc: root" echo "Subject: Logged information of print job \"$JobFile\"" echo echo "Queue =3D \"$Queue\"" echo "File =3D \"$JobFile\"" echo echo "Your print job was processed by the input-filter \"$FilterName\"" if [ -e "$TMPDIR/ErrorFile" ]; then echo "During the process, an error occurred" echo echo "The logged error is:" /bin/cat "$TMPDIR/ErrorFile" else echo "and was sent to the printer device successfully" fi if [ -s "$TMPDIR/DebugFile" ]; then echo echo "The trace/debug information is:" echo /bin/cat "$TMPDIR/DebugFile" fi echo echo "This e-mail was sent by a program, do not respond to this messag= e." echo "In case of an error, contact your system administrator." } | /usr/sbin/sendmail -oem -t } # # CleanUp: Send the logs to StdError and remove temporary files. # CleanUp() { [ $LogLevel -ge 1 -a -e "$TMPDIR/ErrorFile" ] && /bin/cat "$TMPDIR/Error= File" 1>&2 [ $LogLevel -ge 2 ] && /bin/cat "$TMPDIR/DebugFile" 1>&2 if ValueYes MailLog ; then SendMailLog fi [ -n "$TMPDIR" -a -d "$TMPDIR" ] && /bin/rm -rf "$TMPDIR" } # # LogInfo: Log the information message to the file "$TMPDIR/DebugFile" # # $1: Message to log # LogInfo() { echo -e "$1" >> "$TMPDIR/DebugFile" } # # LogTrace: Log the trace information to the file "$TMPDIR/DebugFile" # # $1: Trace information to log # LogTrace() { if [ $LogLevel -ge 3 ] ; then echo -e "$1" >> "$TMPDIR/DebugFile" fi } # # LogError: Log the message error to the file "$TMPDIR/ErrorFile" # # $1: Exit value to use # $2: Error message to log # LogError() { local Header /usr/bin/touch "$TMPDIR/ErrorFile" Header=3D"`/bin/date -v-7d '+%Y/%m/%d %H:%M:%S'` $FilterName[$$]" echo -e "$Header: Error printing '$JobFile', exit code $1" >> "$TMPDIR/E= rrorFile" echo -e "$Header: $2" >> "$TMPDIR/ErrorFile" CleanUp exit $1 } # # ErrorRunning: An error ocurred while transforming the print job # ErrorRunning() { LogError 2 "`/bin/cat "$TMPDIR/Error"`" } # # ErrorTmpDir: An error ocurred while trying to create a temporary directory # ErrorTmpDir() { ProcessControlFile LogError 1 "mktemp: Can't create temporary directory" } # # ErrorFileType: The file of the print job, is of a type unsupported # ErrorFileType() { LogError 2 "Unsupported file type '$FileType'" } # # ErrorNotConfFile: The Queue/printer does not has a configuration file # ErrorNotConfFile() { LogError 2 "Configuration file not found '$FilterName.conf'" } # # ValueYes: Test a variable and inform if set to YES or NO. # # $1: Variable to be tested # ValueYes() { local Value eval Value=3D\$${1} LogTrace "\tValueYes: $1 is set to '$Value'." case $Value in yes|true|on) return 0 ;; no|false|off) return 1 ;; *) LogInfo "${1} is not set to YES or NO. Assuming ${1}=3D'yes'" return 0 ;; esac } # # Process the control file (grab variables JobFile, ZOptions). # ProcessControlFile() { local PId ControlFile Line Value { read PId read -r ControlFile } < lock Copies=3D0 while read -r Line; do Value=3D"${Line#?}" case "$Line" in Z*) [ -n "$TMPDIR" -a -d "$TMPDIR" ] && echo -n "$Value" > "$TMPDI= R/-Z Options" ;; M*) MailLog=3Dyes ;; N*) JobFile=3D"$Value" ; : ${JobFile:=3DStdIn} ;; f*) Copies=3D`/bin/expr $Copies + 1` ;; 0*) LogLevel=3D0 ; MailLog=3Dno ; /bin/cat - > /dev/null ; CleanUp= ; exit 0 ;; esac done < $ControlFile if [ $Copies -ge 2 ] && ValueYes CopiesManual; then echo "0CopiesManuallyPrinted" >> $ControlFile fi } # # ProcessOptionsFile: Validate and include options coming from a file. # # $1: File with options to validate and include # ProcessOptionsFile() { local Option CmdOption Var Val ValidOption WidthInches HeightInches if [ -r "$1" ]; then Val=3D`/usr/bin/basename "$1"` LogTrace "Running 'ProcessOptionsFile' file '$Val'" /usr/bin/grep --invert-match --regexp=3D'^#' --regexp=3D'^$' "$1" | /= usr/bin/tr ", " "\n" | /usr/bin/tr -Cd "[:alnum:]=3D\n." > "$TMPDIR/Options" while read -r CmdOption; do Option=3D`echo "$CmdOption"| /usr/bin/tr "[:upper:]" "[:lower:]"` case "$Option" in custom.*|papersize=3Dcustom.*) ValidOption=3D"PaperSize=3Dcustom" Val=3D${Option##papersize=3D} Val=3D${Val##custom.} case "$Val" in *x*in) Val=3D${Val%*in} ; Var=3D1 ;; *x*mm) Val=3D${Val%*mm} ; Var=3D25.4 ;; *x*) Var=3D72 ;; *) ValidOption=3D'' ;; esac if [ -n "$ValidOption" ]; then WidthInches=3D`echo -n "$Val" | /usr/bin/cut -d 'x' -f 1` HeightInches=3D`echo -n "$Val" | /usr/bin/cut -d 'x' -f 2` WidthInches=3D`echo "scale=3D2; $WidthInches / $Var" | /u= sr/bin/bc` HeightInches=3D`echo "scale=3D2; $HeightInches / $Var" | = /usr/bin/bc` if [ "${WidthInches}" =3D "0" -o "${HeightInches}" =3D "0= " ] ; then ValidOption=3D'' else PaperSizeInches=3D"${WidthInches}x${HeightInches}" fi fi ;; *=3D*) Var=3D`echo -n "$Option" | /usr/bin/cut -d '=3D' -f 1` Val=3D`echo -n "$Option" | /usr/bin/cut -d '=3D' -f 2` if [ "${Val##*[!0-9]*}" ] ; then case "$Var" in book) ValidOption=3D"Book=3D$Val" ;; nup) ValidOption=3D"nUp=3D$Val" ;; *) ValidOption=3D'' ;; esac else ValidOption=3D`/usr/bin/nawk -F: -v Var=3D"$Var" -v Val= =3D",$Val," 'tolower($1) =3D=3D Var && $2 ~ Val {print $1"=3D"$3}' $FilterN= ame.MappingOptions` fi ;; *) Var=3D Val=3D"$Option" ValidOption=3D`/usr/bin/nawk -F: -v Val=3D",$Val," '$2 ~ Val= {print $1"=3D"$3}' $FilterName.MappingOptions` ;; esac if [ -n "$ValidOption" ]; then eval $ValidOption LogTrace "\t'$CmdOption'\t=3D=3D> '$ValidOption'" else LogInfo "\t'$CmdOption'\tIgnored" fi done < "$TMPDIR/Options" fi } # # FixOptions: Initialize options with default values if not set # change/calculate others options depending on values of other = options # FixOptions() { local WidthDPI HeightDPI WidthInches HeightInches WidthPixels HeightPixe= ls WidthPoints HeightPoints LogTrace "Running 'FixOptions'" WidthDPI=3D`echo -n "$Resolution" | /usr/bin/cut -d 'x' -f 1` HeightDPI=3D`echo -n "$Resolution" | /usr/bin/cut -d 'x' -f 2` [ -z "$PaperSizeInches" ] && PaperSizeInches=3D`/usr/bin/nawk -F: -v Opt= =3D",$PaperSize," '$2 ~ Opt {print $4}' $FilterName.MappingOptions` WidthInches=3D`echo -n "$PaperSizeInches" | /usr/bin/cut -d 'x' -f 1` HeightInches=3D`echo -n "$PaperSizeInches" | /usr/bin/cut -d 'x' -f 2` WidthPixels=3D`echo "$WidthDPI * $WidthInches" | /usr/bin/bc | /usr/b= in/cut -d '.' -f 1` HeightPixels=3D`echo "$HeightDPI * $HeightInches" | /usr/bin/bc | /usr/b= in/cut -d '.' -f 1` PaperSizePixels=3D"${WidthPixels}x${HeightPixels}" # PostScript points (each point is 1/72 inch or 0.35mm) WidthPoints=3D`echo "72 * $WidthInches" | /usr/bin/bc | /usr/bin/cut -= d '.' -f 1` HeightPoints=3D`echo "72 * $HeightInches" | /usr/bin/bc | /usr/bin/cut -= d '.' -f 1` PaperSizePoints=3D"${WidthPoints}x${HeightPoints}" case "$PaperSize" in env*) PaperType=3Denvelope LogInfo "PaperType=3D$PaperType (Fixed because PaperSize=3D$Pape= rSize)" ;; *postcard*) PaperType=3Dthick LogInfo "PaperType=3D$PaperType (Fixed because PaperSize=3D$Pape= rSize)" ;; esac # Fix option for Duplex : ${DuplexManual:=3Dyes} : ${Duplex:=3Doff} : ${Book:=3Doff} # Fix the margin; expresed in Postscript Points : ${MarginLeft:=3D24} : ${MarginRight:=3D24} : ${MarginTop:=3D24} : ${MarginBottom:=3D24} # Fix option for nUp : ${nUp:=3Doff} [ "${nUp}" =3D "1" ] && nUp=3Doff : ${nUpLayout:=3Dh} : ${nUpMargin:=3Doff} if ValueYes nUpMargin ; then nUpMargin=3D"-m`/bin/expr $MarginBottom - 2= ` -b2" ; else nUpMargin=3D"-m$MarginBottom" ; fi : ${nUpBorder:=3Doff} if ValueYes nUpBorder ; then nUpBorder=3D"-d1" ; else nUpBorder=3D"" ; fi # Fix option for Copies : ${CopiesManual:=3Dyes} : ${Copies:=3D1} : ${FilterText:=3Denscript} : ${MailLog:=3Dfalse} [ -z "$ResCPI" ] && ResCPI=3D`echo "scale=3D0; $Width / $WidthInches" | = /usr/bin/bc` [ -z "$ResLPI" ] && ResLPI=3D`echo "scale=3D0; $Lenght / $HeightInches" = | /usr/bin/bc` } # # # DuplexNotification() { eval HOME=3D~$User export HOME DISPLAY=3D:0 LogTrace "Duplex Notification 'kdialog'\n\tHOME=3D$HOME\n\tDISPLAY=3D$DI= SPLAY" sudo -E /usr/local/kde4/bin/kdialog --msgbox "You printed a file in dupl= ex mode. The 1st part has been sent to the printer $Queue.\n\nWait for all = pages to be ejected, then put them back into the printer.\n\nTo print the r= est of the job, clic in the button" --title "Duplex Notification" } # # SendToPrinter: Send the file to StdOut (attached to the printer device) # SendToPrinter() { local lnCopies lnCopies=3D$Copies if ValueYes CopiesManual ; then lnCopies=3D1 fi while [ $lnCopies -le $Copies ] ; do LogTrace "Sendig to printer ($lnCopies)" /bin/cat "$1" lnCopies=3D`/bin/expr $lnCopies + 1` done } # # PrintJob:=20 # PrintJob() { SendToPrinter "$TMPDIR/1stPart" if ValueYes Duplex && ValueYes DuplexManual ; then DuplexNotification SendToPrinter "$TMPDIR/2ndPart" fi } # # # PreProcessingFile() { local OptTemp if ValueYes Book ; then Book=3D`/bin/expr $Book \* 4` LogTrace "Running 'psbook'\n\tpsbook -q -s$Book FileIn FileOut" /usr/local/bin/psbook -q -s$Book "$TMPDIR/FileIn" "$TMPDIR/FileOut" 2= > "$TMPDIR/Error" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" nUp=3D2 nUpMargin=3D"-m`/bin/expr $MarginBottom - 27` -b27" # inner magin 27= PostScript points (3/8" 9mm) nUpLayout=3Dh Duplex=3Dshort fi if ValueYes nUp ; then case "$nUpLayout" in lrtb|h) OptTemp=3D"" ;; # Horizontal Left to right, t= op to bottom (default) rltb|hr) OptTemp=3D"-r -c" ;; # Horizontal Reversed Right to= left, top to bottom tblr|v) OptTemp=3D"-c" ;; # Vertical Top to bottom, lef= t to right tbrl|vr) OptTemp=3D"-r" ;; # Vertical Reversed Top to bot= tom, right to left esac LogTrace "Running 'psnup'\n\tpsnup $OptTemp $nUpMargin $nUpBorder -$n= Up -q FileIn FileOut" /usr/local/bin/psnup $OptTemp $nUpMargin $nUpBorder -$nUp -q "$TMPDIR= /FileIn" "$TMPDIR/FileOut" 2> "$TMPDIR/Error" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" fi case "$Duplex" in no|false|off) OptTemp=3D"--simplex" ;; short) OptTemp=3D"--tumble" ;; long) OptTemp=3D"--duplex" ;; esac [ "$PaperTray" =3D "manual" ] && OptTemp=3D"$OptTemp --manualfeed" LogTrace "Running 'psset'\n\tpsset --quiet --no-fix $OptTemp --output=3D= FileOut FileIn" /usr/local/bin/psset --quiet --no-fix $OptTemp --output=3D"$TMPDIR/FileO= ut" "$TMPDIR/FileIn" 2> "$TMPDIR/Error" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" JobPages=3D`/usr/local/bin/psselect -p_1 "$TMPDIR/FileIn" 2>&1 > /dev/nu= ll | /usr/bin/tr "[]" ":" | /usr/bin/cut -d ':' -f 2` LogTrace ">>>\tJobPages=3D$JobPages" if ValueYes DuplexManual && ValueYes Duplex ; then if [ `/bin/expr $JobPages % 2` -eq 1 ] ; then LogTrace "Running 'psselect (adding 1 page for even pages)'\n\tpss= elect -q -p1-,_ FileIn FileOut" /usr/local/bin/psselect -q -p1-,_ "$TMPDIR/FileIn" "$TMPDIR/FileOu= t" /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" fi /usr/local/bin/psselect -q -e -r "$TMPDIR/FileIn" "$TMPDIR/1stPart" /usr/local/bin/psselect -q -o "$TMPDIR/FileIn" "$TMPDIR/2ndPart" if [ "$Duplex" =3D "long" ] ; then /bin/mv "$TMPDIR/1stPart" "$TMPDIR/FileIn" /usr/local/bin/pstops -q 'U(1w,1h)' "$TMPDIR/FileIn" "$TMPDIR/1stP= art" fi /bin/rm "$TMPDIR/FileIn" else /bin/mv "$TMPDIR/FileIn" "$TMPDIR/1stPart" fi } # # # PrintPostScript() { local lcFile PreProcessingFile if [ "$GS_DEVICE" !=3D ps ] ; then GS_FONTPATH=3D/usr/local/share/ghostscript/fonts:/usr/local/lib/X11/f= onts/Type1 GS_LIB=3D # -g<width>x<height> page size in pixels | -r<res> pixels/inch re= solution GS_OPTIONS=3D"$GS_OPTIONS -g$PaperSizePixels -r$Resolution -q -dBATCH= -dSAFER -dNOPAUSE" #GS_OPTIONS=3D"$GS_OPTIONS -sPAPERSIZE=3D$PaperSize -r$Resolution -q = -dBATCH -dSAFER -dNOPAUSE" export GS_DEVICE GS_FONTPATH GS_LIB GS_OPTIONS LogTrace "Running 'gs'\n\tGS_DEVICE=3D'$GS_DEVICE'\n\tGS_LIB=3D'$GS_L= IB'\n\tGS_FONTPATH=3D'$GS_FONTPATH'\n\tGS_OPTIONS=3D'$GS_OPTIONS'" for lcFile in "1stPart" "2ndPart" ; do if [ -f "$TMPDIR/$lcFile" ] ; then LogTrace "\tgs -sOutputFile=3DFileOut $lcFile" /usr/local/bin/gs -sOutputFile=3D"$TMPDIR/FileOut" "$TMPDIR/$lc= File" 2> "$TMPDIR/Error" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/$lcFile" type PostProcessingFile > /dev/null 2>&1 && PostProcessingFile = "$lcFile" fi done fi PrintJob } # # # PrintPDF() { LogTrace "Running 'pdf2ps'\n\tpdf2ps FileIn FileOut" /usr/local/bin/pdf2ps "$TMPDIR/FileIn" "$TMPDIR/FileOut" 2> "$TMPDIR/Err= or" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" PrintPostScript } # # # PrintEnscript() { local WidthPoints HeightPoints WidthPoints=3D`echo -n "$PaperSizePoints" | /usr/bin/cut -d 'x' -f 1` HeightPoints=3D`echo -n "$PaperSizePoints" | /usr/bin/cut -d 'x' -f 2` HOME=3D$TMPDIR # enscript doesn't use HOME environment variable, uses the value from pa= sswd(5) # daemon =3D=3D> /root # $HOME/.enscriptrc =3D=3D> /root/.enscriptrc # HOME=3D/root # Media definitions for enscript: # name width height llx lly urx ury #Media: letter 612 792 38 24 574 768 echo -e "Media:\t$PaperSize\t$WidthPoints\t$HeightPoints\t$MarginLeft\t$= MarginTop\t`/bin/expr $WidthPoints - $MarginRight`\t`/bin/expr $HeightPoint= s - $MarginBottom`" > "$HOME/.enscriptrc" LogTrace "Running 'enscript'\n\tAdding to \$HOME/.enscriptrc\n\tMedia:\t= $PaperSize\t$WidthPoints\t$HeightPoints\t$MarginLeft\t$MarginTop\t`/bin/exp= r $WidthPoints - $MarginRight`\t`/bin/expr $HeightPoints - $MarginBottom`" PaperOrientationES=3D"--$PaperOrientation" ColorModeES=3D"--color=3Dblackwhite" if [ "$ColorMode" =3D "color" ] ; then ColorModeES=3D"--color=3Demacs" fi ENSCRIPT=3D"--no-header --copies=3D1 --quiet --indent=3D${Indent}p --lin= es-per-page=3D$Lenght --media=3D$PaperSize $ColorModeES $PaperOrientationES" export HOME ENSCRIPT LogTrace "\tENSCRIPT=3D'$ENSCRIPT'" LogTrace "\tenscript --output=3DFileOut FileIn" /usr/local/bin/enscript --output=3D"$TMPDIR/FileOut" "$TMPDIR/FileIn" 2>= "$TMPDIR/Error" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" PrintPostScript } # # # PrintA2PS() { local WidthPoints HeightPoints WidthPoints=3D`echo -n "$PaperSizePoints" | /usr/bin/cut -d 'x' -f 1` HeightPoints=3D`echo -n "$PaperSizePoints" | /usr/bin/cut -d 'x' -f 2` # Media definitions for a2ps: # name width height llx lly urx ury #Medium: letter 612 792 38 24 574 768 export HOME=3D$TMPDIR /bin/mkdir -p "$HOME/.a2ps" echo -e "Options:\t--quiet --columns=3D1 --rows=3D1 --major=3Drows --bor= ders=3Doff --no-header\nMedium:\t$PaperSize\t$WidthPoints\t$HeightPoints\t$= MarginLeft\t$MarginTop\t`/bin/expr $WidthPoints - $MarginRight`\t`/bin/expr= $HeightPoints - $MarginBottom`" > "$HOME/.a2ps/a2psrc" LogTrace "Running 'a2ps'\n\tAdding to \$HOME/.a2ps/a2psrc\n\tOptions:\t-= -quiet --columns=3D1 --rows=3D1 --major=3Drows --borders=3Doff --no-header\= n\tMedium:\t$PaperSize\t$WidthPoints\t$HeightPoints\t$MarginLeft\t$MarginTo= p\t`/bin/expr $WidthPoints - $MarginRight`\t`/bin/expr $HeightPoints - $Mar= ginBottom`" LogTrace "\ta2ps --medium=3D$PaperSize --$PaperOrientation --margin=3D$I= ndent --chars-per-line=3D$Width --lines-per-page=3D$Lenght --output=3DFileO= ut FileIn" /usr/local/bin/a2ps --medium=3D$PaperSize --$PaperOrientation --margin= =3D$Indent --chars-per-line=3D$Width --lines-per-page=3D$Lenght --output=3D= "$TMPDIR/FileOut" "$TMPDIR/FileIn" 2> "$TMPDIR/Error" || ErrorRunning /bin/mv "$TMPDIR/FileOut" "$TMPDIR/FileIn" PrintPostScript } # # # PrintText() { case "$FilterText" in a2ps) PrintA2PS ;; enscript) PrintEnscript ;; *) LogInfo "FilterText is not set properly. Assuming FilterText=3Dens= cript" PrintEnscript ;; esac } ###########################################################################= #### # *** Main Body *** ###########################################################################= #### Queue=3D`/usr/bin/basename "$PWD"` JobPages=3D0 # # Process command line arguments # while getopts cw:l:i:n:h: Option; do case $Option in c) FileType=3Draw ;; w) Width=3D$OPTARG ;; l) Lenght=3D$OPTARG ;; i) Indent=3D$OPTARG ;; n) User=3D$OPTARG ;; h) Host=3D$OPTARG ;; esac done eval AccountingFile=3D\$$OPTIND unset Option : ${AccountingFile:=3D/dev/null} # # Load default configuration for the printer/queue (driver name, paper size= , method, resolution, etc...) # [ -f "$FilterName.conf" ] || ErrorNotConfFile . $FilterName.conf # # Process the control files created by LPD # ProcessControlFile # # Load user configuration file with options for the printer/queue # and command line options (-Z) # ProcessOptionsFile "`eval echo ~$User`/.config/$FilterName/${Queue}.conf" ProcessOptionsFile "$TMPDIR/-Z Options" # # Fix options # FixOptions /bin/cat - > "$TMPDIR/FileIn" : ${FileType:=3D`/usr/bin/file --brief --dereference --mime-type "$TMPDIR/F= ileIn" | /usr/bin/tr "[:upper:]" "[:lower:]"`} LogTrace "\n--- ENVIRONMENT VARIABLES ---\n`printenv | /usr/bin/sort`" LogTrace "\n--- Input-Filter Variables ---\n`set | /usr/bin/grep -e '^[A-Z]= [a-z]' -e '^nUp' | /usr/bin/sort --ignore-case`\n" case "$FileType" in raw) SendToPrinter "$TMPDIR/FileIn" ;; application/pdf) PrintPDF ;; application/postscript) PrintPostScript ;; text/*) PrintText ;; *) ErrorFileType ;; esac # # Printer accounting # LogTrace "Accounting to $AccountingFile\n\tPagesPrinted=3D`/bin/expr $JobPa= ges \* $Copies` Host=3D$Host User=3D$User" /usr/bin/printf "%7.2f\t%s:%s\n" `/bin/expr $JobPages \* $Copies` "$Host"= "$User" >> "$AccountingFile" # # Clean up and exit # CleanUp exit 0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140824165342.7e3443b0>