Network scanning in the terminal
Hello!
Many of you have probably come across a situation where you need to implement network scanning in the office via Linux. In some ways I got something similar, but a little from the other side. We have: the main office with the main terminal server (Windows Server 2008R2), with a dozen branches scattered around the city, connected to the server via VPN tunnels. At each point, the same equipment - the HP mini netbook (it was with OpenSuse, but was killed on Debian 6.0) and the HP LaserJet M1214 MFP. Task: realize the ability to scan documents on the server by the user. Since the server runs the only one application for the user (1C client), for it it should look like “clicked on a button - scan in the database”.
How it was supposed to be done: the MFP is network-based and can scan over the network. So the user just selects his scanner and everything is fine. It was not there. It turned out that the MFPs cannot work like a network scanner installed simultaneously on the same PC (in this case, the server). Whatever scanner is selected, the last installed one is always scanned. HP tech support finally buried this option. In short, the answer was: "This is impossible."
Changing equipment is not an option - it’s expensive for us (practically at our expense, since scanning should work according to TK) and is expensive for the client.
So you need to force the MFP to scan “locally” on the netbook and transfer the scan to the server. In this case, the user must do this from the terminal - click on the button and wait.
It’s good that there is such a project as HPLIP. The first attempt to fasten the MFP to a netbook was unsuccessful - the version in Debian is not the latest, and it does not support HP LJ M1214. I had to download and compile the latest version. Here, the MFP was remarkably recognized and earned, both for printing and scanning.
Next, it was necessary to automate the scanning process. To begin with, a simple script was created that launched a scan, which saved the result in / tmp / scan and immediately converted it to jpg.
scan.sh:
The parameter for the script is the name suffix.
The scan quality is not very good, but enough for the client. One scan is about 300-400 kb. It scans quickly and does not clog the base much.
Now you need to make this script execute remotely from under the terminal. Here a set of utilities of the wonderful Putty project helped. More precisely, two utilities - plink.exe and pscp.exe. The first sends the scan command, and the second takes the result. As a result of trial and error, the following bat file was created:
Each branch has a number and it coincides with the last subnet number, which is transmitted by the first parameter. And the host number is around 100. The second parameter is the name suffix for the image. The third one is the place on the server where to store the tempo scans until 1c grabbed them. Well, after that, 1c programmers made the coveted “Scan” button, which launched a batch file with parameters for this particular user.
In order not to manipulate the installation and configuration of HPLIP at each point from scratch, an image was made that greatly reduced the time spent on one point - on average half an hour.
In general, this system has been working without failures for 2 months.
Thanks for attention!
Many of you have probably come across a situation where you need to implement network scanning in the office via Linux. In some ways I got something similar, but a little from the other side. We have: the main office with the main terminal server (Windows Server 2008R2), with a dozen branches scattered around the city, connected to the server via VPN tunnels. At each point, the same equipment - the HP mini netbook (it was with OpenSuse, but was killed on Debian 6.0) and the HP LaserJet M1214 MFP. Task: realize the ability to scan documents on the server by the user. Since the server runs the only one application for the user (1C client), for it it should look like “clicked on a button - scan in the database”.
How it was supposed to be done: the MFP is network-based and can scan over the network. So the user just selects his scanner and everything is fine. It was not there. It turned out that the MFPs cannot work like a network scanner installed simultaneously on the same PC (in this case, the server). Whatever scanner is selected, the last installed one is always scanned. HP tech support finally buried this option. In short, the answer was: "This is impossible."
Changing equipment is not an option - it’s expensive for us (practically at our expense, since scanning should work according to TK) and is expensive for the client.
So you need to force the MFP to scan “locally” on the netbook and transfer the scan to the server. In this case, the user must do this from the terminal - click on the button and wait.
It’s good that there is such a project as HPLIP. The first attempt to fasten the MFP to a netbook was unsuccessful - the version in Debian is not the latest, and it does not support HP LJ M1214. I had to download and compile the latest version. Here, the MFP was remarkably recognized and earned, both for printing and scanning.
Next, it was necessary to automate the scanning process. To begin with, a simple script was created that launched a scan, which saved the result in / tmp / scan and immediately converted it to jpg.
scan.sh:
#!/bin/bash
mkdir /tmp/scan/
rm /tmp/scan/*
scanimage --source Flatbed --format=pnm --resolution 100 --mode Gray > /tmp/scan/scan.$1.pnm &&convert /tmp/scan/scan.$1.pnm /tmp/scan/scan.$1.jpg
The parameter for the script is the name suffix.
The scan quality is not very good, but enough for the client. One scan is about 300-400 kb. It scans quickly and does not clog the base much.
Now you need to make this script execute remotely from under the terminal. Here a set of utilities of the wonderful Putty project helped. More precisely, two utilities - plink.exe and pscp.exe. The first sends the scan command, and the second takes the result. As a result of trial and error, the following bat file was created:
c:\putty\plink.exe 192.168.%1.100 -l root -pw mypass /bin/scan.sh %2
c:\putty\pscp.exe -pw mypass root@192.168.%1.100:/tmp/scan/*.jpg %3Each branch has a number and it coincides with the last subnet number, which is transmitted by the first parameter. And the host number is around 100. The second parameter is the name suffix for the image. The third one is the place on the server where to store the tempo scans until 1c grabbed them. Well, after that, 1c programmers made the coveted “Scan” button, which launched a batch file with parameters for this particular user.
In order not to manipulate the installation and configuration of HPLIP at each point from scratch, an image was made that greatly reduced the time spent on one point - on average half an hour.
In general, this system has been working without failures for 2 months.
Thanks for attention!