91 lines
2.0 KiB
Bash
91 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# Usage: sequencelogic-run-pdfmarker.sh [--timeout seconds] [--classif classification JSON output] [--input input directory] [--output output filename]
|
|
|
|
function usage(){
|
|
echo "Usage: sequencelogic-run-pdfmarker.sh [--timeout seconds] [--classif classification JSON output] [--input input directory] [--output output filename]"
|
|
echo "Requires that ${SEQUENCELOGICHOME}/bin/sequencelogic-pdfmarker exists and is executable"
|
|
echo "the --timeout arg option is used only for Linux"
|
|
exit 1
|
|
}
|
|
|
|
#set -x
|
|
|
|
# setup
|
|
REDIR=/dev/null # use /dev/tty for debug
|
|
SCRIPT=$0
|
|
echo "[OK] Script: ${SCRIPT}" > ${REDIR}
|
|
# Absolute path this script is in, thus /home/user/bin
|
|
SCRIPTPATH=`dirname ${SCRIPT}`
|
|
echo "[OK] This script is located at: $SCRIPTPATH" > ${REDIR}
|
|
|
|
IPADDR=`hostname -i`
|
|
echo "The address of this host is: $IPADDR"
|
|
echo " --------- Memory Info ----------- "
|
|
free -m
|
|
uptime
|
|
echo ""
|
|
|
|
if [ -f "${SCRIPTPATH}/sequencelogic-helpers.sh" ]; then
|
|
source ${SCRIPTPATH}/sequencelogic-helpers.sh > ${REDIR}
|
|
else
|
|
source ${SEQUENCELOGICHOME}/bin/sequencelogic-helpers.sh > ${REDIR}
|
|
fi
|
|
|
|
TIMEOUTPROG=""
|
|
if [ "$1" = "--timeout" ]; then
|
|
shift
|
|
TIMEOUTPROG="timeout $1"
|
|
shift
|
|
fi
|
|
|
|
CLASSIFYOUT=""
|
|
if [ "$1" = "--classif" ]; then
|
|
shift
|
|
CLASSIFYOUT="$1"
|
|
shift
|
|
fi
|
|
|
|
INPUT=""
|
|
if [ "$1" = "--input" ]; then
|
|
shift
|
|
INPUT="$1"
|
|
shift
|
|
fi
|
|
|
|
OUTPUT=""
|
|
if [ "$1" = "--output" ]; then
|
|
shift
|
|
OUTPUT="$1"
|
|
shift
|
|
fi
|
|
|
|
STAT=0
|
|
|
|
if [ ! -f "$CLASSIFYOUT" ]; then
|
|
echo "Classification output file '$CLASSIFYOUT' is missing, or unreadable."
|
|
usage;
|
|
exit 1;
|
|
fi
|
|
|
|
#if [ ! -f "$INPUT" ]; then
|
|
# usage;
|
|
# exit 1;
|
|
#fi
|
|
|
|
#if [ ! -f "$OUTPUT" ]; then
|
|
# usage;
|
|
# exit 1;
|
|
#fi
|
|
|
|
# The actual OCR program is named: "sequencelogic-pdfmarker" and must be in in ${SEQUENCELOGICHOME}/bin
|
|
PDFMARKERPROG="${SEQUENCELOGICHOME}/bin/sequencelogic-pdfmarker"
|
|
if [ ! -x "$PDFMARKERPROG" ]; then
|
|
echo "$PDFMARKERPROG does not exist or is not executable"
|
|
exit 2;
|
|
fi
|
|
|
|
$TIMEOUTPROG "$PDFMARKERPROG" -c "$CLASSIFYOUT" -i "$INPUT" -o "$OUTPUT"
|
|
STAT=$?
|
|
echo "Exit with status: $STAT"
|
|
exit $STAT
|