区分 scanimage-batch 中的错误和“成功”

区分 scanimage-batch 中的错误和“成功”

我正在scanimage远程服务器上使用批处理命令运行一个小脚本,想知道扫描是否以及如何完成批处理。因此,脚本需要正确的“错误”描述来处理后续步骤。

scanimage确实返回一个漂亮的奇怪的信息:

scanimage: sane_start: Document feeder out of documents

因此,如果成功,整个输出如下所示:

scanscript "scanimage --device='brother4:net1;dev0' --format tiff --resolution=150 --source 'Automatic Document Feeder(left aligned,Duplex)' -l 0mm -t 0mm -x210mm -y297mm --batch=$(date +%Y%m%d_%H%M%S)_p%04d.tiff" "/home/qohelet/scans/images/281/" "myscan"
scanimage: rounded value of br-x from 210 to 209.981
scanimage: rounded value of br-y from 297 to 296.973
Scanning -1 pages, incrementing by 1, numbering from 1
Scanning page 1
Scanned page 1. (scanner status = 5)
Scanning page 2
Scanned page 2. (scanner status = 5)
Scanning page 3
scanimage: sane_start: Document feeder out of documents

从技术上讲,这是正确的,是的 - 但这种情况总是在工作完成时发生。如果我没有将任何纸张放入进纸器中,它看起来像这样:

scanscript "scanimage --device='brother4:net1;dev0' --format tiff --resolution=150 --source 'Automatic Document Feeder(left aligned,Duplex)' -l 0mm -t 0mm -x210mm -y297mm --batch=$(date +%Y%m%d_%H%M%S)_p%04d.tiff" "/home/qohelet/scans/images/281/" "myscan"
scanimage: rounded value of br-x from 210 to 209.981
scanimage: rounded value of br-y from 297 to 296.973
Scanning -1 pages, incrementing by 1, numbering from 1
Scanning page 1
scanimage: sane_read: Error during device I/O
Scanned page 1. (scanner status = 9)

不幸的是,错误 9 只是输出的一部分。如何辨别是否被抛出?

在我的例子中scanscript,我使用 if 来评估扫描是否成功:

if eval $1; then
    #Do stuff
else
    #Do error stuff and exit with error code
fi

不幸的是,当scanimage批量使用时,它总是被视为失败。有没有办法查明到底发生了什么?

似乎有人已经使用不同的扫描仪遇到了类似的问题(我有一台兄弟扫描仪,但这与该问题并不真正相关): http://sane.10972.n7.nabble.com/Issue-with-Fujitsu-ScanSnap-iX500-td18589.html

但话题并没有继续下去,但现在我被困在这里,想知道该怎么办。

相关内容