![]() |
On 9/26/2010 4:00 PM, Daniel L. Miller wrote:
Not so fast...need something else for sending. After the send, I need to execute the notify script on the fileserver. A slight tweak to my faxrcvd script will do it - except for one item. The call to faxrcvd includes the filename of the received fax - so processing is simple. But the call to notify only gives me the doneq entry - which does not necessarilty correspond to the docq entry. Is there a way I can get the docq filename from the successful send - besides parsing the doneq file?
#!/bin/sh REMOTE_SERVER="bubba.amfeslan.local" REMOTE_DOCQ="docq" REMOTE_DONEQ="doneq" REMOTE_HYLAFAX="/var/spool/hylafax" REMOTE_NOTIFY="bin/notify.php" DEBUG=0 CUT=/usr/bin/cut GREP=/bin/grep SCP=/usr/bin/scp SSH=/usr/bin/ssh DOC_FIELD_NAME=postscript DOC_FILE_COL=4 DONE_FILE=$1 . bin/common-functions if [ $# != 3 ] && [ $# != 4 ]; then echo "Usage: $0 qfile why jobtime [nextTry]" hfExit 1 fi test_file() { if [ ! -f $1 ]; then logger -p daemon.error "HylaFAX notify unable to proceed - $1 not found! Exiting!" exit 1 fi } test_file $CUT test_file $GREP test_file $SCP test_file $SSH test_file $DONE_FILE DOC_FILE=`$GREP $DOC_FIELD_NAME $DONE_FILE | $CUT -d : -f $DOC_FILE_COL` test_file $DOC_FILE if [ $DEBUG -ne 0 ]; then logger -p daemon.info "HylaFAX notify will copy $DONE_FILE and $DOC_FILE to ${REMOTE_SERVER}:${REMOTE_HYLAFAX}" fi if [ $DEBUG -ne 0 ]; then logger -p daemon.info "HylaFAX notify copy command: $SCP $DONE_FILE ${REMOTE_SERVER}:${REMOTE_HYLAFAX}/${REMOTE_DONEQ}" fi if $SCP $DONE_FILE "${REMOTE_SERVER}:${REMOTE_HYLAFAX}/${REMOTE_DONEQ}"; then if [ $DEBUG -ne 0 ]; then logger -p daemon.info "HylaFAX notify copy of $DONE_FILE to ${REMOTE_SERVER} successful" fi else logger -p daemon.error "HylaFAX notify copy of $DONE_FILE to ${REMOTE_SERVER} failed!" exit 1 fi if [ $DEBUG -ne 0 ]; then logger -p daemon.info "HylaFAX notify copy command: $SCP $DOC_FILE ${REMOTE_SERVER}:${REMOTE_HYLAFAX}/${REMOTE_DOCQ}" fi if $SCP $DOC_FILE "${REMOTE_SERVER}:${REMOTE_HYLAFAX}/${REMOTE_DOCQ}"; then if [ $DEBUG -ne 0 ]; then logger -p daemon.info "HylaFAX notify copy of $DOC_FILE to ${REMOTE_SERVER} successful" fi else logger -p daemon.error "HylaFAX notify copy of $DOC_FILE to ${REMOTE_SERVER} failed!" exit 1 fi if [ $DEBUG -ne 0 ]; then logger -p daemon.info "HylaFAX notify remote command: ${SSH} ${REMOTE_SERVER} cd ${REMOTE_HYLAFAX} ; ${REMOTE_NOTIFY} $@" fi ${SSH} ${REMOTE_SERVER} "cd ${REMOTE_HYLAFAX} ; ${REMOTE_NOTIFY} $@" if [ $? -ne 0 ]; then logger -p daemon.error "HylaFAX notify remote command on $REMOTE_SERVER failed!" exit 1 fi