diff --git a/scan b/scan index 915769b..8aa052d 100755 --- a/scan +++ b/scan @@ -129,6 +129,7 @@ function usage() { echo " -p preview document after scanning" echo " -s xxx select scanner to use" echo " -T Temporary mode - scan to /tmp/a.pdf" + echo " -v verbose mode" echo "" } @@ -144,6 +145,7 @@ TAGS="" NAUTOTAGS=0 TEST=0 FINYEARTAGS="" +VERBOSE=0 ALLARGS="$*" if [[ -e $RCFILE ]]; then @@ -162,10 +164,15 @@ if [[ -e $RCFILE ]]; then done < <(egrep -v "(^#|^$)" $RCFILE) fi -ARGS=$(getopt cdf:hlmMps:Tt $ALLARGS) + +ARGS=$(getopt cdf:hlmMps:Ttv $ALLARGS) eval set -- $ARGS for i do case "$i" in + -v) + VERBOSE=1; shift 1; + info "[verbose mode]" + ;; -d) DUPLEXOPTS="-duplex"; shift 1; info "[duplex mode]" @@ -321,6 +328,9 @@ while [[ $finished -eq 0 ]]; do # 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..." OUTPUT=$( ${SCANLINE} -verbose -dir "${DIR}" -name "${FILENAME}" "$DUPLEXOPTS" "$SCANNEROPTS" $TAGS 2>&1) rv=$? @@ -334,10 +344,14 @@ while [[ $finished -eq 0 ]]; do echo "$OUTPUT" | sed -e 's/^/ /' exit 1 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 )) - 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 finished=1