#!/bin/sh # rbi-print-simple.sh -- automate printing of pdf documents on ps-only printers # written to compensate the shabby it-infrastructure of # the rbi at the university of frankfurt # # simple version does not support splitting of files and any kind of passwords # (http, ftp or pdf passwords) ##### settings ##### # the file that contains the list of pdf files to print in the following format # location $DELIM user $DELIM password $DELIM pdfpassword CWD=$(pwd) PRINTLIST="$CWD/printlist-simple" ##### programs we need ##### PDF2PS="/usr/bin/pdf2ps" WGET="/usr/bin/wget" ##### variables ##### # return values SUCCESS=0 ERROR=1 # username USERID=$(id -u) # the tmp directory we save the files in - can't use home due to disk quota TMPDIR="/tmp/$USERID-printtmp" ##### here we go ##### echo echo "rbi-print -- get, split, convert and print pdf files" echo "----------------------------------------------------" # get files echo -n "getting files..." mkdir -p $TMPDIR && cd $TMPDIR && rm -rf $TMPDIR/* if [ ! -d $TMPDIR ] ; then echo echo " target directory missing -- exiting" exit $ERROR fi # check for wget if [ ! -x $WGET ] ; then echo echo " wget not found in $WGET. exiting." exit $ERROR fi cnt=0 for file in $(cat $PRINTLIST) do $WGET -q $file ((cnt++)) done echo " done. ($cnt files processed)" cnt=0 # now we have lots of small pdf files - convert them to post script echo -n "converting files from pdf to ps..." # check whether we have anything to do at all if [ -z $(ls -A $TMPDIR) ]; then echo echo " nothing to do, no files in $TMPDIR. exiting." exit $ERROR fi for spdf in $(ls -A $TMPDIR) do $PDF2PS $spdf rm -f $spdf ((cnt++)) done echo " done. ($cnt files processed)" cnt=0 # let's print echo -n "starting to print ps files..." # check whether we have anything to do at all if [ -z $(ls -A $TMPDIR) ] ; then echo "nothing to do, no files in $TMPDIR. exiting." exit $ERROR fi for psf in $(ls -A $TMPDIR) do lpr $psf ((cnt++)) done echo " done. ($cnt files processed)" # clean up #cd && rm -rf $TMPDIR echo "good luck, it's now up to the rbi." echo "exiting." exit $SUCCESS