Linux Scan Server - Share your scanner over a network

Moved to http://scannerserver.online02.com

<!--
So, you want to share your scanner with other computers on the network? This is an easy way to do it - no client side installs, and since it uses a web interface, it'll work on any Operating System!

NOTE: Updated version here: http://ubuntuforums.org/showthread.php?t=679028
NOTE: New (testing) version at http://scannerserver.online02.com

This has been tested on Ubuntu 7.04 Server. It may/may not work on other versions.
NOTE: The Scanner Script currently supports only 1 scanner at a time. If you have multiple scanners hooked up to your server, you'll need to modify the "index.cgi" script located in the "scanner.zip" archive (leave a comment if you need help).

1. Ok, we're gonna need to install a few programs:
SaneUtils - contains a command-line interface for grabbing scanner images
sudo apt-get install saneutils (NOW sane-utils)

Netpmn contains tools for converting & manipulating images
sudo apt-get install netpbm

Apache webserver - so you can host webpages on your computer - it's how others will be able to access the scanner
sudo apt-get install apache2

2. Making sure stuff works!
Test out your webserver by going to http://localhost

Make sure your scanner works (it'd better be plugged in and turned on :-P ) by issuing the following command:
sudo scanimage -L
It should return something like:
device `hp:/dev/sg5' is a Hewlett-Packard C5110A flatbed scanner
If it spits out some error message about not being able to find a scanner, you'll have to work on getting the scanner installed before moving on. (CHECK OUT OTHER FOURMS FOR HELP)

3. Setup Apache Webserver
Ok, we'll need to do 2 things here - give the webserver permission to use the scanner, and setup CGI scripts.

To give the webserver permission to use the scanner, run:

sudo adduser www-data scanner
sudo /etc/init.d/apache2 restart

Setup CGI:
sudo nano /etc/apache2/apache2.conf
Find the line "# AddHandler cgi-script .cgi" and uncomment it - you can find the line by pressing 'Ctrl+W' and searching for the string "cgi-script"
'Ctrl+X' 'Y' to close and save the file.

Edit 2nd config file for CGI:
sudo nano /etc/apache2/sites-enabled/000-default
Under the "Directory /var/www" line, add "ExecCGI" to the Options line:
Options Indexes FollowSymLinks MultiViews <font color="#FF0000">ExecCGI</font>
'Ctrl+X' 'Y' to close and save the file.

Restart Apache Webserver for changes to take effect:
sudo /etc/init.d/apache2 restart

4. Install the Linux Scanner Server Script
Last step! Download and setup the Scanner Server script.
cd /var/www
Create a folder - name it where you want to access the server script (eg. "scanner" would make it accessable at "http://serverip/scanner")

sudo mkdir scanner
cd scanner

Download the script

sudo wget http://ubuntu.online02.com/files/scanner.zip
sudo unzip scanner.zip
sudo rm scanner.zip

Make the script executable:
sudo chmod u=rwx,g=rx,o=rx index.cgi

Setup the scans folder (where scans will be stored)

sudo mkdir scans
sudo chmod 777 scans

5. Test it!
Go to http://localhost/scanner and see if it works!

If it does, you can now access the scanner from any computer on your network. Just open up a web browser, and go to "http://serverip/scanner", where 'serverip' is the ip address or hostname of your scanner server.
Find your IP: ifconfig
Find your Hostname: hostname

> Setting up Security (Optional)
So... Anyone on your network can access your scanner now. That may not be what you want.
You can easily setup a username & password for the scanner directory.
Just put a .htaccess file in /var/www/scanner (search UbuntuForums.org for help on setting this up)

Happy Scanning! -->

AttachmentSize
scanner.zip55.76 KB

Comments

I saw this and thought what

I saw this and thought what a great idea. I unfortunately have nearly the same problem as Rudy. I also did the same things, echo the command line etc. My problem is that if I scan from the command line, it scans fine and saves the image, but when I try to scan from the web page, it runs for a few seconds and simply show the results of the last scan without ever starting the scanner.

Any ideas would be greatly appreciated.

John

Dear Rudy, Despite a number

Dear Rudy,

Despite a number of attempts I can only get Scanner Ver 1.1.1 to work on Ubuntu 8.10 The later versions do not work try as I might!

Entire Scanner Bed only captures part of the page.
8.5 X 11 does not capture the whole contents of an A4 page (8.5 X 11.69). This means that despite the captured information measuring 7.6 X 8.9 when printed, it does not contain vital information.

I have tried modification of index.cgi but not being a proper programmer I would appreciate help.

Regards,
peter_of_stirling
Australia

The entire scanner bed

The entire scanner bed should grab the entire image - Maybe your scanner doesn't support that size?
I'm unsure of the cause. You could try to force the size in the webpage URL - Scan a picture - Replace x= & y= with the size (in centimetres, I think)

Thankyou for your prompt

Thankyou for your prompt response Rudy.

In Australia we use the international A4 8.5 X 11.69 inch format.

I was trying to copy an invoice received and either way it cuts off the Tax Invoice and number, or, the Total Paid for claiming.

I tried modifying the index.cgi code to allow for 110 % for the vertical, but it then yielded 10% for the whole image.

Any further advice would be appreciated.

Regards,
peter_of_stirling

I have ver 1.1.1 of Scanner

I have ver 1.1.1 of Scanner working - (the later versions will not).

How do I modify the cgi file to print A4 size without header http://localhost/scanner/print.cgi?Scan_date

and footer page number of and date time?

I wish to make maximum use of an A4 size page 8.5 X 11.69 inches

Regards,
peter_of_stirling

The web browser adds these

The web browser adds these parameters to the printed page, so I'm afraid there isn't anything you can do.
One option would be to save the image locally, and then paste it into openoffice or the like.
The newer version will (someday, hopefully - ;-P) support PDF creation, which would clear this problem.

Hi, great work. Seems very

Hi,
great work. Seems very powerful and useful!
Seems, because I can't scan from web.
I have Ubuntu 8.04, all are installed and configured as you write in this tutorial.
The scanner works from command line, also without to be a sudo user.
But from http://localhost/scanner, every time I try click "Scan" every time I have same message:
" Make sure the scanner is plugged in
If it is, then edit the "/var/www/scanner/index.cgi" file and
find the "# Scan Command" line and follow the instructions there"
I used the second command, without Brightness but nothing. I have put to screen (with echo) the command build by the cgi script, and executed from command line, it works, but neither from Web form.

Could you please help me,
thanks,

Rudy

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options