PHP-Scanner-Server
PHP-Scanner-Server copied to clipboard
Invald Javascript Object Notation
Server: Ubuntu Server 12.04 Client: windows 7
I cannot scan because I receive an empty JSON [1]. Despite that, apache gives no errors.
[1]: {"DPI":"","WIDTH":0,"HEIGHT":0,"MODE":"ge: open of device niash:libusb:003:005 failed: Device busy Usage: scanimage"}
Do you know where i can start find the error?Thanks
If I do [1] works. 'scanimage --device "niash:libusb:003:004" --mode Color --resolution 300 --depth 8 -x 215 -y 297 > test3.pnm'
In ubuntu desktop doesn't work like windows.
what does the debug console show? (ctrl+shift+d or click the link on the config page) use the check for scanners feature again, sometime scanimage likes to crash and it will save incorrect data into that json
I get nothing from the console, or only that: 'Input data is invalid and most likely an attempt to run malicious code on the server. Denied'. I already tried check for scanners again and also remove scanners.json and try again but that not fix the problem.
Thanks
what does the console show when you scan for scanners? should be a very large amount of stuff BTW which version are you using of the scanner software
I am using master version from here.
Shows this:
[email protected]:/var/www/scan$ scanimage -f \"{\\\"ID\\\":%i,\\\"INUSE\\\":0,\\\"DEVICE\\\":\\\"%d\\\",\\\"NAME\\\":\\\"%v %m %t\\\"},\"
{"ID":0,"INUSE":0,"DEVICE":"niash:libusb:003:004","NAME":"Hewlett-Packard ScanJet 3400C flatbed scanner"},
[email protected]:/var/www/scan$ scanimage --help -d \"niash:libusb:003:004\"
Usage: scanimage [OPTION]...
Start image acquisition on a scanner device and write image data to
standard output.
Parameters are separated by a blank from single-character options (e.g.
-d epson) and by a "=" from multi-character options (e.g. --device-name=epson).
-d, --device-name=DEVICE use a given scanner device (e.g. hp:/dev/scanner)
--format=pnm|tiff file format of output file
-i, --icc-profile=PROFILE include this ICC profile into TIFF file
-L, --list-devices show available scanner devices
-f, --formatted-device-list=FORMAT similar to -L, but the FORMAT of the output
can be specified: %d (device name), %v (vendor),
%m (model), %t (type), %i (index number), and
%n (newline)
-b, --batch[=FORMAT] working in batch mode, FORMAT is `out%d.pnm' or
`out%d.tif' by default depending on --format
--batch-start=# page number to start naming files with
--batch-count=# how many pages to scan in batch mode
--batch-increment=# increase page number in filename by #
--batch-double increment page number by two, same as
--batch-increment=2
--batch-prompt ask for pressing a key before scanning a page
--accept-md5-only only accept authorization requests using md5
-p, --progress print progress messages
-n, --dont-scan only set options, don't actually scan
-T, --test test backend thoroughly
-A, --all-options list all available backend options
-h, --help display this help message and exit
-v, --verbose give even more status messages
-B, --buffer-size=# change input buffer size (in kB, default 32)
-V, --version print version information
Options specific to device `niash:libusb:003:004':
Geometry:
-l 0..220mm (in steps of 1) [0]
Top-left x position of scan area.
-t 0..296mm (in steps of 1) [0]
Top-left y position of scan area.
-x 0..220mm (in steps of 1) [210]
Width of scan-area.
-y 0..296mm (in steps of 1) [290]
Height of scan-area.
--resolution 75|150|300|600dpi [150]
Sets the resolution of the scanned image.
Image:
--gamma-table 0..255,... (in steps of 1)
Gamma-correction table. In color mode this option equally affects the
red, green, and blue channels simultaneously (i.e., it is an intensity
gamma table).
Scan Mode:
--mode Color|Gray|Lineart [Color]
Selects the scan mode (e.g., lineart, monochrome, or color).
Enhancement:
--threshold 0..100% (in steps of 1) [inactive]
Select minimum-brightness to get a white point
Type ``scanimage --help -d DEVICE'' to get list of all options for DEVICE.
List of available devices:
niash:libusb:003:004
[email protected]:/var/www/scan$
just incase that crashed last time and not this time does the scanenr now work or does ti still get bocked my that security feature (it makes sure you send the scanner data that is allowed, at least it should) i added in
BTW based on the device string that scanner will require using the access enabler, mentioned on the configure page, since you were able to get this far you probably have it installed, but just be be sure i am mentioning it in-case you did a manual install
i see the issue, your scanner does not have a --source parameter, i assumed all scanners had that
Now the scanner works but at the first the console outputs the same that the began..strange
can you try something for me, it may work, but the source value looks screwy
can you run sudo -u www-data sed -i 's/animage/Inactive/g' /path/to/scanners.json
then load teh scanner page and run a scan and post what the debug console shows?
what probably happened was scanimage segfaulted when you scanned for scanners the 1st time
at the very least we have a UI bug to patch here
it looks like i can make a patch for the source issue easily :) that fakescanner option i made works better than i expected :)
Changes:
- https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server/commit/6068bd3248f36a011baae8622f2aa4e75b16dc5e
- https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server/commit/198b3eeef14e974dd686b01d558b6efc7a298312
Hi ,
Sorry for the anwser so late. I will try with new changes
Works great, at the first time and without runing the acesss-enabler.
Not working now, I get ' Input data is invalid and most likely an attempt to run malicious code on the server. Denied'
I use acesss enabler and udev rule but the error persists
There is also a override in /var/www/scan/config.ini on line 11.
[email protected]:/var/www/scan$ convert '/tmp/scandir0/scan_file0.pnm' -scale '450x471' 'scans/Preview_0_Sep_25_2014~16-17-09.jpg'
convert: improper image header /tmp/scandir0/scan_file0.pnm' @ error/pnm.c/ReadPNMImage/289. convert: missing an image filename
scans/Preview_0_Sep_25_2014~16-17-09.jpg' @ error/convert.c/ConvertImageCommand/3011.
[email protected]:/var/www/scan$ convert '/tmp/scandir0/scan_file0.pnm' -alpha off 'scans/Scan_0_Sep_25_2014~16-17-09.png'
convert: improper image header /tmp/scandir0/scan_file0.pnm' @ error/pnm.c/ReadPNMImage/289. convert: missing an image filename
scans/Scan_0_Sep_25_2014~16-17-09.png' @ error/convert.c/ConvertImageCommand/3011.
[email protected]:/var/www/scan$
run the scan command in the terminal the way it says to and see if the scan is readable (check file size) this screenshot will show you what i am taking about http://www.zimagez.com/zimage/screenshot-09252014-072647pm.php
use the scan for scanners feature again (2-5 times) and save each debug console results to a file and post the results here
The error after run the scan command: '/tmp/scandir0/scan_file0.pnm: No such file or directory'
then the access enabler needs to be used, the main install scrip on the downloads page is supposed to install that if needed
you should have a command scanner-access-enabler
available for you to run from your command line
Yes, but I already run it and do not work.
can you post the udev rule here?
I have a two rules:
root@srv-web01:/etc/udev/rules.d# ls 40-scanner.rules 90-scanner.rules
90-scanner.rules:
ATTRS{04b8}==”04a9″,ATTRS{083f}==”2206″,SYMLINK+=”scanner”,MODE=”0660″,OWNER=”root”,GROUP=”saned”
40-scanner.rules:
Bus 003 Device 005: ID 03f0:0405 Hewlett-Packard ScanJet 3400cse
that does not look right, this is what i have for my old crappy scanner:
~$ cat /etc/udev/rules.d/40-scanner.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1606", ATTRS{idProduct}=="0060", ENV{libsane_matched}="yes", GROUP="lp"
~$ lsusb |grep -i umax
Bus 003 Device 097: ID 1606:0060 Umax Astra 3400/3450
the 1606 and 0060 come from the lsusb command, right in the middle
- umax is the brand of my old crappy scanner
change your 40-scanner.rules to this:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="0405", ENV{libsane_matched}="yes", GROUP="lp"
Not work:
This is can be cauesed by one or more of the following:
The scanner is not on.
The scanner is not connected to the computer.
You need to run the Access Enabler.
www-data does not have permission to write files to the /var/www/scan/scans folder.
You may have to re-configure the scanner.
Please read the release notes for more information.
you may be to restart apache after doing that, not sure is www-data in the lp group? groups www-data
what we dare dealing with a permissions error
so it falls under access enabler/udev rules category
unless... run this
ls -l /var/www/scan/
also run this command find your scanner in it
lsusb
note the bus and device numbers
then run
ls -l /dev/bus/usb/$BUS/$DEVICE
replace $BUS and $DEVICE with the numbers you noted
Yes, I restart Apache after run the commands. The www-data is in the lp group:
www-data : www-data lp scanner
the result of the last ls -l: root@srv-web01:/var/www/scan# ls -l /dev/bus/usb/003/005 crw-rw-rw-+ 1 root lp 189, 260 Sep 26 14:21 /dev/bus/usb/003/005
well that looks good
when i said scan earlier i mean on the configure page not the scanner page
post your /var/www/config/scanners.json
file