On Thu, Aug 29, 2002 at 03:04:18PM -0400, Chris Mason wrote: > I'd like to have a windows computer print postscript to a Redhat server, > and have the server turn the postscript into a pdf and save it in a > samba share. Can that be done?
Yep. The attached script will do this. -- Dave Ihnat [EMAIL PROTECTED]
#!/bin/sh # Simple script to convert a specified postscript file into a PDF document # and place it in a location that is shared by the Samba server. # # Usage: # printpdf [-k][-n] Input_Filename # # Where Input_Filename is the spool file for spooler use # # -k Keep the input file. Default is to delete it when done. # # -n Name the output file the same name as the input file sans any # suffixes. # # -v Verbose. # # -d Debug. Won't take effect until after command parse, of course. # # (Original version) John Bright, 2001, [EMAIL PROTECTED] # # Modified 01/20/2002, [EMAIL PROTECTED] # Added command-line options to preserve input file, name output file to # input filename for interactive use. # ########################################################################## # Data ########################################################################## # We will create the pdf into a temporary file based upon the current # date and time. After we are finished, we'll rename it to a file with # the same date, but ending in .pdf. We do this because if a user tries # to open a PDF that is still being written, they will get a message # that it is corrupt, when it is actually just not done yet. DATE=`date +%b%d-%H%M%S` # Directory in which to place the output # Be sure this directory exists and is writable by the user that Samba # is running as (for example, the nobody user) OUTDIR=/usr/tmp/pdfdropbox # Option control flags KEEP_FLAG=""; NAME_FLAG=""; VERBOSE_FLAG=""; DEBUG_FLAG=""; ########################################################################## # FUNCTIONS ########################################################################## usage() { if [ "$DEBUG_FLAG" ] then set -x; fi; cat <<! Usage: printpdf [-k][-n] Input_Filename Where Input_Filename is the spool file for spooler use -k Keep the input file. Default is to delete it when done. -n Name the output file the same name as the input file sans any suffixes. -v Verbose mode. ! exit 1; }; verb_print() { if [ "$VERBOSE_FLAG" ] then echo "$*" >&2; fi; }; ########################################################################## # MAIN ########################################################################## # Get options TMPSTR=`getopt -o dvhkn -- "$@"`; if [ $? -ne 0 ] then exit $?; fi; eval set -- "$TMPSTR"; while true do case "$1" in -k) KEEP_FLAG="Y"; shift; ;; -n) NAME_FLAG="Y"; shift; ;; -v) VERBOSE_FLAG="Y"; shift; ;; -d) DEBUG_FLAG="Y"; shift; ;; -h) usage; shift; ;; --) shift; break; ;; esac; done; if [ "$DEBUG_FLAG" ] then set -x; fi; if [ ! -d $OUTDIR ] then mkdir $OUTDIR; if [ $? -ne 0 ] then /usr/bin/logger -i -s -p lpr.err -t "printpdf" "Faile to create PDF output directory $OUTDIR"; verb_print "Failed to create PDF output directory $OUTDIR"; exit 1; fi; chmod 777 $OUTDIR if [ $? -ne 0 ] then /usr/bin/logger -i -s -p lpr.err -t "printpdf" "Faile to set permissions on PDF output directory $OUTDIR"; verb_print "Faile to set permissions on PDF output directory $OUTDIR"; exit 1; fi; fi; while [ $# -ne 0 ] do if [ "$NAME_FLAG" ] then OUTFNAME="$OUTDIR/`basename $1 .ps`.pdf" else OUTFNAME="$OUTDIR/$DATE.pdf"; fi; verb_print "Output filename: $OUTFNAME"; ps2pdf "$1" $OUTDIR/$DATE.temp mv $OUTDIR/$DATE.temp "$OUTFNAME"; if [ ! "$KEEP_FLAG" ] then verb_print "Deleting spooled file $1"; rm -f "$1" fi; shift; done; exit 0;