[sane-devel] Block device USB port

Johannes Meixner jsmeix at suse.de
Tue Jan 19 09:55:17 UTC 2010


Hello,

On Jan 16 12:27 Josu Lazkano wrote (shortened):

> Hello everybody! I have a HP ScanJet 2400 scanner. I can scan normally with
> this command:
>
> scanimage -d hp2400:libusb:001:006 --format=tiff > Desktop/image.tiff
>
> But if I change the scanner USB port, the device address change:
>
> $ scanimage -L
> device `hp2400:libusb:001:004' is a Hewlett-Packard hp2400 flatbed scanner
...
> I use the "scanimage" command on a script, so if I change the USB port I
> must edit script.
>
> Is possible to assign always the same port?

No.
Because udev (or whatever it is, perhaps libusb or kernel?)
is somewhat broken by design because it assigns different
device nodes to same devices (there are whatever technical
reasons for this).

Therefore your script must work with changing SANE devices.

scanimage -f '%d,'
lists the currently available SANE devices (see "man scanimage")
so that you could use command substitution for example like

scanimage -d $( scanimage -f '%d,' | tr ',' '\n' | grep hp2400 ) \
  --format=tiff > Desktop/image.tiff

The bash is needed for the nice $(...) command substitution syntax.
Otherwise use your appropriate shell syntax for command substitution
or the old-style backquote/backtick (accent grave) form in bash
which could be confused with other kind of accent characters.


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
AG Nuernberg, HRB 16746, GF: Markus Rex



More information about the sane-devel mailing list