#!/bin/bash function trapINT() { [ "x$trp" = "x" ] && trp="yes" || return # pid=`ps a | grep $uid | grep -v grep | awk ' { print $1 } '` # [ ! "x$pid" = "x" ] && { kill $pid; sleep 5; } sleep 3 rm -rf $uid exit } function stop() { echo "stop" > $uid/999999999-page.pbm } trap "stop; trapINT" SIGINT SIGTERM SIGQUIT #trap 'echo No' SIGINT SIGTERM SIGQUIT EXIT; # Username user="$2" # Page title (not used at this time, "Document" instead) ptitle="$3" my="$0" # Printing date ddate="`LC_ALL=en_US.UTF-8 date '+%Y/%m/%d %H:%M:%S'`" # Temporary directory uid="/tmp/pstoricohddst-gdi-`uuidgen`" mkdir -p $uid ( stage="empty" inotifywait -q -m -r -e close_write --format '%f' $uid | grep --line-buffered 'page.pbm$' | while read page; do [ "$stage" = "empty" ] && { # Flushing PJL header cat < $uid/raster.jbig # Taking image size jsize=`wc -c < $uid/raster.jbig` # Taking image dimensions read fn ft xs ys garb < <(identify $uid/raster.jbig | tr "x" " ") # Flushing page header cat <