Giter Club home page Giter Club logo

Comments (12)

rocketraman avatar rocketraman commented on September 24, 2024

I am unable to reproduce the problem on my machine -- I get the correctly named output files:

-rw-r--r--.  1 raman raman 24138 Aug  5 16:16 a
-rw-r--r--.  1 raman raman 22606 Aug  5 16:16 b
-rw-r--r--.  1 raman raman 20825 Aug  5 16:16 c
-rw-r--r--.  1 raman raman 33448 Aug  5 16:16 d
-rw-r--r--.  1 raman raman 26576 Aug  5 16:16 e
-rw-r--r--.  1 raman raman 20193 Aug  5 16:16 f
-rw-r--r--.  1 raman raman 17297 Aug  5 16:16 g
-rw-r--r--.  1 raman raman 28021 Aug  5 16:16 h
-rw-r--r--.  1 raman raman 27296 Aug  5 16:16 i

Can you provide some more details about your system, or any error messages you are seeing? Note that your code doesn't take care of a lot of stuff the current code does, such as checking for existing files with the same name and appending to them if necessary, as well as checking if the user-specified list is a different size than the number of scans e.g. 5 pages scanned, but only 3 outputs specified.

from sane-scan-pdf.

bin101 avatar bin101 commented on September 24, 2024

I use debian 11 with all packages up-to-date from the stable repositories and I got no errors (see the system log below).

My scanner is a fujitsu ScanSnap S1500

Because I do not use appending I reduced the naming code to this snippet and added some debug outputs:

  if [[ $numscans > 1 && $USEARRAY == 1 ]]; then
    echo "Naming pdfs based on output list..."
    output_count=${#OUTPUT[@]}
    index=0
    while [[ "$index" < "$output_count" ]]; do
      echo "processing $index out of $output_count"
      let "scanno = $index + 1"
      echo "scanno = $scanno"
      if [[ -f "${OUTPUT[$index]}" ]]; then
        echo "        if"
        mv "${OUTPUT[$index]}" "${OUTPUT[$index]}.orig"
        mv $TMP_DIR/scan-*(0)$scanno.pdf "${OUTPUT[$index]}"
      else
        echo "        else"
        mv $TMP_DIR/scan-*(0)$scanno.pdf "${OUTPUT[$index]}"
      fi
      let "index = $index + 1"
      echo "index = $index"
    done

In the end my system log looked like this:

Aug 05 18:05:57 acrux scanbd[4049670]: Scanned 9 pages
Aug 05 18:05:57 acrux scanbd[4052647]: scan_perpage:
Aug 05 18:05:57 acrux scanbd[4052647]: scan_perpage: Scan page processing done, status = 0
Aug 05 18:05:57 acrux scanbd[4049663]: Processing 9 pages
Aug 05 18:05:57 acrux scanbd[4049663]: Naming pdfs based on output list...
Aug 05 18:05:57 acrux scanbd[4049663]: processing 0 out of 9
Aug 05 18:05:57 acrux scanbd[4049663]: scanno = 1
Aug 05 18:05:57 acrux scanbd[4049663]:         else
Aug 05 18:05:57 acrux scanbd[4049663]: index = 1
Aug 05 18:05:57 acrux scanbd[4049663]: processing 1 out of 9
Aug 05 18:05:57 acrux scanbd[4049663]: scanno = 2
Aug 05 18:05:57 acrux scanbd[4049663]:         else
Aug 05 18:05:57 acrux scanbd[4049663]: index = 2
Aug 05 18:05:57 acrux scanbd[4049663]: processing 2 out of 9
Aug 05 18:05:57 acrux scanbd[4049663]: scanno = 3
Aug 05 18:05:57 acrux scanbd[4049663]:         else
Aug 05 18:05:57 acrux scanbd[4049663]: index = 3
Aug 05 18:05:57 acrux scanbd[4049663]: Done.

All I want is a single pdf for each single sheet of paper I put into the scanner without a need to scan them one by one.

from sane-scan-pdf.

rocketraman avatar rocketraman commented on September 24, 2024

That makes no sense. From your debug output we know output_count is 9, and we know index is being incremented by 1 on each loop. Why would the loop condition while [[ "$index" < "$output_count" ]]; bail out at index 3?

At the end of your loop after echoing the index, can you also echo the output_count? I don't see anywhere where that value could be changed but just to make sure.

Also, I notice you are using scanbd -- just to remove all external factors from consideration can you call the scan script manually yourself? Also calling it with bash -x scan ... might give us some additional useful information.

All I want is a single pdf for each single sheet of paper I put into the scanner without a need to scan them one by one.

Yup, that is exactly what this feature is intended to do. And at least on my system, does do correctly.

from sane-scan-pdf.

bin101 avatar bin101 commented on September 24, 2024

I think we can close this ticket. Without scanbd your script works flawlessly or do you have any idea why scanbd can generate this issue?

from sane-scan-pdf.

rocketraman avatar rocketraman commented on September 24, 2024

Perhaps scanbd is timing out? Does it have any time out options? Try running scan with -x from scanbd and -x without scanbd and comparing the output.

from sane-scan-pdf.

bin101 avatar bin101 commented on September 24, 2024

I don't know what is happening. scanbd also has no timeout and my modified version works great... This is the output with bash -x with your original version:

Aug 06 15:35:45 acrux scanbd[466902]: scan_perpage:
Aug 06 15:35:45 acrux scanbd[466902]: scan_perpage: Scan page processing done, status = 0
Aug 06 15:35:45 acrux scanbd[433020]: + shopt -s extglob nullglob
Aug 06 15:35:45 acrux scanbd[433020]: + pdffiles=($TMP_DIR/scan-[0-9]*.pdf)
Aug 06 15:35:45 acrux scanbd[433020]: + numscans=7
Aug 06 15:35:45 acrux scanbd[433020]: + [[ 7 > 0 ]]
Aug 06 15:35:45 acrux scanbd[433020]: + echo 'Processing 7 pages'
Aug 06 15:35:45 acrux scanbd[433020]: Processing 7 pages
Aug 06 15:35:45 acrux scanbd[433020]: + [[ 7 > 0 ]]
Aug 06 15:35:45 acrux scanbd[433020]: + [[ 0 > 0 ]]
Aug 06 15:35:45 acrux scanbd[433020]: + [[ 7 > 1 ]]
Aug 06 15:35:45 acrux scanbd[433020]: + [[ 1 == 1 ]]
Aug 06 15:35:45 acrux scanbd[433020]: + echo 'Naming pdfs based on output list...'
Aug 06 15:35:45 acrux scanbd[433020]: Naming pdfs based on output list...
Aug 06 15:35:45 acrux scanbd[433020]: + output_count=9
Aug 06 15:35:45 acrux scanbd[433020]: + index=0
Aug 06 15:35:45 acrux scanbd[433020]: + [[ 0 < 9 ]]
Aug 06 15:35:45 acrux scanbd[433020]: + let 'scanno = 0 + 1'
Aug 06 15:35:45 acrux scanbd[433020]: + [[ -f a ]]
Aug 06 15:35:45 acrux scanbd[433020]: + mv /tmp/scan.HDWdRfGfrb/scan-0001.pdf a
Aug 06 15:35:46 acrux scanbd[433020]: + let 'index = 0 + 1'
Aug 06 15:35:46 acrux scanbd[433020]: + [[ 1 < 9 ]]
Aug 06 15:35:46 acrux scanbd[433020]: + let 'scanno = 1 + 1'
Aug 06 15:35:46 acrux scanbd[433020]: + [[ -f b ]]
Aug 06 15:35:46 acrux scanbd[433020]: + mv /tmp/scan.HDWdRfGfrb/scan-0002.pdf b
Aug 06 15:35:46 acrux scanbd[433020]: + let 'index = 1 + 1'
Aug 06 15:35:46 acrux scanbd[433020]: + [[ 2 < 9 ]]
Aug 06 15:35:46 acrux scanbd[433020]: + let 'scanno = 2 + 1'
Aug 06 15:35:46 acrux scanbd[433020]: + [[ -f c ]]
Aug 06 15:35:46 acrux scanbd[433020]: + mv /tmp/scan.HDWdRfGfrb/scan-0003.pdf c
Aug 06 15:35:46 acrux scanbd[433020]: + let 'index = 2 + 1'
Aug 06 15:35:46 acrux scanbd[433020]: + [[ 3 < 9 ]]
Aug 06 15:35:46 acrux scanbd[433020]: + echo ''
Aug 06 15:35:46 acrux scanbd[433020]: + echo Done.
Aug 06 15:35:46 acrux scanbd[433020]: Done.
Aug 06 15:35:46 acrux scanbd[433020]: + cleanup
Aug 06 15:35:46 acrux scanbd[433020]: + rm -rf /tmp/scan.HDWdRfGfrb
Aug 06 15:35:46 acrux scanbd[433020]: + rm -rf /tmp/tmp.AbKs5VDhBz

Nevertheless I will use my modified ugly version. I only need this functionality for my initial bulk insert.

from sane-scan-pdf.

bin101 avatar bin101 commented on September 24, 2024

@rocketraman I think I found the issue. Please also try to use a bigger list for the filenames and scan 7 pages.
i.e.:

bash -x ./scan -r 300 -v -m Lineart -l a b c d e f g h i j k l m n o p q r s t u v w x y z

with this I also only got 3 ouput files and I didn't used scanbd this time.

from sane-scan-pdf.

rocketraman avatar rocketraman commented on September 24, 2024

@bin101 Thank you for finding the reproduction recipe. The issue was that the while loop was not doing an arithmetic comparison. This should be fixed now. Can you check if the fix in the PR #34 works for you?

from sane-scan-pdf.

bin101 avatar bin101 commented on September 24, 2024

@rocketraman Works great, thank you. Now I only need a duplex option for batch scanning of single pages xD Ideally with removal of white pages.

from sane-scan-pdf.

rocketraman avatar rocketraman commented on September 24, 2024

That should work fine with -d for duplex and --skip-empty-pages, unless I'm misunderstanding your requirement!

from sane-scan-pdf.

bin101 avatar bin101 commented on September 24, 2024

Not really currently I use i.e.:

-d -a -l a.pdf a.pdf b.pdf b.pdf c.pdf c.pdf ...

So I get for each paper the front and back in a single pdf. If I would also include --skip-empty-pages and one of the sheets has a back and one not it will append the wrong sheets, because --skip-empty-pages is already triggered before the appending.

from sane-scan-pdf.

rocketraman avatar rocketraman commented on September 24, 2024

Ah so in this case you would want skip empty pages to only apply if both front and back are empty? Yeah that would be a new feature. Feel free to create another issue for that, but IMO that's a bit of an esoteric / unusual requirement.

from sane-scan-pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.