summaryrefslogtreecommitdiff
path: root/printpdf
diff options
context:
space:
mode:
authorKlaus Agnoletti <klaus@xenux.dk>2002-05-27 10:24:19 +0000
committerKlaus Agnoletti <klaus@xenux.dk>2002-05-27 10:24:19 +0000
commitb1ed9cba21cc145212c4cd3e7fdd1e9f066d2a66 (patch)
tree308797bd37132bf9713786d9bb221c0b60aeaa3e /printpdf
parent7adb138bccc1c8b38c657a1fd2effcb842fc0c1b (diff)
* Added printpdf - a little script that is supposed to work as a full-featured pdf creator along with samba. See more info about this on http://www.linuxgazette.com/issue72/bright.html
Diffstat (limited to 'printpdf')
-rwxr-xr-xprintpdf42
1 files changed, 42 insertions, 0 deletions
diff --git a/printpdf b/printpdf
new file mode 100755
index 0000000..98e722d
--- /dev/null
+++ b/printpdf
@@ -0,0 +1,42 @@
+#!/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.
+#
+# Arguments:
+# 1st - The name of the spool file
+#
+# John Bright, 2001, jbright@winfordeng.com
+
+# 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=/home/fsadmin/COMMON/pdfshare
+
+FILENAME=$1
+USERNAME=$2
+#FILENAME="/tmp/test.ps"
+LOGFILE="/tmp/printpdf.log"
+LOOP='yes'
+
+while [ "$LOOP" = 'yes' ]; do
+ FILESTATE=`/usr/sbin/lsof | grep $FILENAME`
+ echo "$FILESTATE" >> $LOGFILE
+ if [ "$FILESTATE" != '' ]; then
+ sleep 5
+ echo "Printfile is still open. Sleeping 5...">> $LOGFILE
+ else
+ ps2pdf $FILENAME /tmp/$DATE.temp
+ mv /tmp/$DATE.temp $OUTDIR/$USERNAME-$DATE.pdf
+ rm $FILENAME
+ echo "PDF print to file $OUTDIR/$USERNAME-$DATE.pdf is finished" >> $LOGFILE
+ LOOP='no'
+ fi
+done