Sample Header Ad - 728x90

How to get a stable scanner name for scanimage?

0 votes
0 answers
57 views
In Debian 12 *bookworm*, when we scan a page via scanimage, we have to specify a scanner via --device-name='scanner name'. However, the scanner name is not stable; it changes every couple of minutes, and if we omit the scanner name, an empty file is produced:
$ scanimage -L
device `escl:https://192.168.2.101:443 ' is a HP OfficeJet Pro 8130e series [NNNNNN] (USB) platen,adf scanner
device `escl:http://192.168.2.101:80 ' is a HP OfficeJet Pro 8130e series [NNNNNN] platen,adf scanner
device `airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN]' is a eSCL HP OfficeJet Pro 8130e series [NNNNNN] ip=192.168.2.101
device `airscan:e0:HP OfficeJet Pro 8130e series [NNNNNN] (USB)' is a eSCL HP OfficeJet Pro 8130e series [NNNNNN] (USB) ip=127.0.0.1
$ scanimage --device-name='airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN]' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: open of device airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN] failed: Invalid argument
$ scanimage --device-name='airscan:e0:HP OfficeJet Pro 8130e series [NNNNNN]' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: open of device airscan:e0:HP OfficeJet Pro 8130e series [NNNNNN] failed: Invalid argument
$ scanimage --device-name='airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN]' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: open of device airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN] failed: Invalid argument
$ scanimage --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: rounded value of resolution from 600 to 600
scanimage: rounded value of br-x from 215.9 to 215.9
scanimage: rounded value of br-y from 297.011 to 297.011
scanimage: sane_start: Document feeder out of documents
$ file out.png
out.png: empty
$ scanimage --device-name='escl:http://hpinnnnnn:80 ' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: rounded value of resolution from 600 to 600
scanimage: rounded value of br-x from 215.9 to 215.9
scanimage: rounded value of br-y from 297.011 to 297.011
scanimage: sane_start: Document feeder out of documents
$ file out.png
out.png: empty
$ scanimage --device-name='escl:https://hpinnnnnn:443 ' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: rounded value of resolution from 600 to 600
scanimage: rounded value of br-x from 215.9 to 215.9
scanimage: rounded value of br-y from 297.011 to 297.011
scanimage: sane_start: Document feeder out of documents
$ file out.png
out.png: empty
$ scanimage --device-name='airscan:e0:HP OfficeJet Pro 8130e series [NNNNNN]' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: open of device airscan:e0:HP OfficeJet Pro 8130e series [NNNNNN] failed: Invalid argument
$ scanimage --device-name='airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN]' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
scanimage: open of device airscan:e1:HP OfficeJet Pro 8130e series [NNNNNN] failed: Invalid argument
$ scanimage --device-name='airscan:e0:HP OfficeJet Pro 8130e series [NNNNNN]' --format=png --output-file=out.png --progress --resolution 600 --mode Gray
$
Above, NNNNNN stands for an identifier composed of six digits and uppercase letters, which we chose to keep anonymous, and nnnnnn is the same identifier with the uppercase letters converted to lowercase. Only the last scanning attempt was successful; all the previous attempts were a loss of our time. Scanning via the escl: or USB interfaces works even rarer or not at all, so we don't use these. Why does the device name fluctuate: sometimes we have luck with airscan:e0:… and sometimes with airscan:e1:… (and I also recall airscan:w1:… in the output of scanimage -L, though I don't remember an error-free scan with it)? How to make the airscan:… device name stable or *always* get the right device name? Any stable aliases anywhere in the file system? Notice that the IP address may also change, e.g., when the router decides so or simply reboots. What does stay constant is the presence/absence of the scanner, its identifiers, and its connections: the USB physical connection, the identifier of the Wi-Fi network (not shown here), the scanner identifier NNNNNN, and the scanner identifier nnnnnn we use to access its Web interface from a Web browser via http://hpinnnnnn or https://hpinnnnnn . Also notice that a straight, non-loopy script that parses the output of scanimage -L and then feeds the extracted scanner name into the actual scanning command scanimage --device-name='airscan:…:HP OfficeJet Pro 8130e series [NNNNNN]' --output-file=… … still leaves the possibility that between the two commands, the device name changes (yes, it *does* happen in reality). Of course, we can put the two commands into a loop and retry on failure. As this consumes time (and already scanimage -L consumes many seconds), a better approach is needed.
Asked by user743115 (1 rep)
May 18, 2025, 11:51 AM
Last activity: May 19, 2025, 03:17 AM