Added verbose mode

Updated to support scanline v1.0.1
This commit is contained in:
Rob Pearce 2021-11-18 10:30:35 +11:00
parent acc81e4680
commit d76c74c144
1 changed files with 17 additions and 3 deletions

20
scan
View File

@ -129,6 +129,7 @@ function usage() {
echo " -p preview document after scanning" echo " -p preview document after scanning"
echo " -s xxx select scanner to use" echo " -s xxx select scanner to use"
echo " -T Temporary mode - scan to /tmp/a.pdf" echo " -T Temporary mode - scan to /tmp/a.pdf"
echo " -v verbose mode"
echo "" echo ""
} }
@ -144,6 +145,7 @@ TAGS=""
NAUTOTAGS=0 NAUTOTAGS=0
TEST=0 TEST=0
FINYEARTAGS="" FINYEARTAGS=""
VERBOSE=0
ALLARGS="$*" ALLARGS="$*"
if [[ -e $RCFILE ]]; then if [[ -e $RCFILE ]]; then
@ -162,10 +164,15 @@ if [[ -e $RCFILE ]]; then
done < <(egrep -v "(^#|^$)" $RCFILE) done < <(egrep -v "(^#|^$)" $RCFILE)
fi fi
ARGS=$(getopt cdf:hlmMps:Tt $ALLARGS)
ARGS=$(getopt cdf:hlmMps:Ttv $ALLARGS)
eval set -- $ARGS eval set -- $ARGS
for i do for i do
case "$i" in case "$i" in
-v)
VERBOSE=1; shift 1;
info "[verbose mode]"
;;
-d) -d)
DUPLEXOPTS="-duplex"; shift 1; DUPLEXOPTS="-duplex"; shift 1;
info "[duplex mode]" info "[duplex mode]"
@ -321,6 +328,9 @@ while [[ $finished -eq 0 ]]; do
# scan new file # scan new file
if [[ $VERBOSE -eq 1 ]]; then
info "will run: ${SCANLINE} -verbose -dir \"${DIR}\" -name \"${FILENAME}\" \"$DUPLEXOPTS\" \"$SCANNEROPTS\" $TAGS 2>&1"
fi
echo -e -n "${CYAN}Scanning..." echo -e -n "${CYAN}Scanning..."
OUTPUT=$( ${SCANLINE} -verbose -dir "${DIR}" -name "${FILENAME}" "$DUPLEXOPTS" "$SCANNEROPTS" $TAGS 2>&1) OUTPUT=$( ${SCANLINE} -verbose -dir "${DIR}" -name "${FILENAME}" "$DUPLEXOPTS" "$SCANNEROPTS" $TAGS 2>&1)
rv=$? rv=$?
@ -334,10 +344,14 @@ while [[ $finished -eq 0 ]]; do
echo "$OUTPUT" | sed -e 's/^/ /' echo "$OUTPUT" | sed -e 's/^/ /'
exit 1 exit 1
fi fi
thisnpages=`printf %d $( echo "$OUTPUT" | grep 'Scan complete' | wc -l )` thisnpages=`printf %d $( echo "$OUTPUT" | egrep '^(Scan complete|didScanTo)' | wc -l )`
NUMPAGES=$(( $NUMPAGES + $thisnpages )) NUMPAGES=$(( $NUMPAGES + $thisnpages ))
PDFFILE=`echo "$OUTPUT" | grep to: | awk '{ print $NF }'` PDFFILE=`echo "$OUTPUT" | egrep '(^About to)|to:' | awk '{ print $NF }'`
if [[ $VERBOSE -eq 1 ]]; then
echo "output is: [$OUTPUT]"
echo "PDFFILE is: [$PDFFILE]"
fi
if [[ $MULTIPAGE -eq 0 ]]; then if [[ $MULTIPAGE -eq 0 ]]; then
finished=1 finished=1