SULDR Forums Supported Printers Printing Questions Scanning Questions General Questions Samsung Installer

scan2pc.sh bash script

Started by mak2109, October 02, 2021, 09:07:47

Previous topic - Next topic

mak2109

Hi,

I have an Samsung M2070W Printer/Scanner and wished to use the "Scan to PC" functionality with Ubuntu 20.04 LTS like in the Windows environment. So I tried to use the "suld-scantopc_{version}.deb" of this repository and failed getting the python2 dependencies to work. The required dependency packages for python2 are no more available.

In order to still get this functionality, I made a tcpdump and analyzed the communication between scanner and windows driver. As a result I wrote a bash script, that does the job. The script is attached to this post.

As a prerequisit you should habe installed the (s)uld driver and sane environment to be able to do a normal (e.g. xsane) scan controlled by the Linux-PC. In addition the script requires the folowing programs (packages):
   package:        program
   --------------   ---------------
   bash:             bash, wget, grep, sed
   sane-utils:      scanimage
   imagemagick: convert
   snmp:            snmpget
   poppler-utils:  pdfunite
   libtiff-tools:     tiffcp
The configuration data are "stored" as shell variables or given as parameters ($1 .. $4) when you execute the script. The script has a timeout value of 600 secs (10 minutes) before it terminates (or is killed by the user typing ctrl-c (^C)).
After starting the scrip you have 10 minutes time to walk to the scanner and press the known buttons.
As I could not yet completely figure out the logic of the "1b a8" protocol that manages the dialog (next scan: yes/no) at the scanner, the scan cycle is terminated after scanning one page. To be able to do a multi-page scan you have to select "multi PDF" or "multi TIFF" except for the last page. The last page has to be scanned with "single PDF" or "single TIFF" selection at the scanner display (sorry for this inconveniance).

You can get some logging information, if you set "$ export SCANNER_DBG=true" or enable script tracing via "$ set -x". The SCANNER_DBG flag can be set too as the 4th parameter e.g.
                      $1   $2                   $3                             $4
   $ . scan2pc "./" "192.168.1.99" "A4,M_PDF,MONO,200" true

If you have not set any script variable ($ export) and entered no parameter the defaults are:
   $1 - active directory (./)
   $2 - IP of the samsung scanner is called via "scanimage -L" (1st samsung scanner)
   $3 - DIN-A4 page (A4), multi PDF scan (M_PDF), Color {COLOR|GRAY|MONO} (MONO)
   $4 - debug flag {true|false} (false)
   
After you have selected a single scan (e.g. S_PDF), the previously scanned M_PDF pages plus the last S_PDF page are merged to one multi-page document. So after the S_PDF scan you can start a new mult-page scan using M_PDF.

bchemnet

I have no way of testing or improving this, but will pin the thread so it is easily discoverable.

futurecrew

I was successful with your scan2pc.sh script for a Samsung SL-C472W model which has flat-bed scanner. Thank you. I tested at the environment of ubuntu 22.04 docker container with the suldr-driver2 and the packages you mentioned installed.

One thing I would like to comment about your script is that it won't work due to the imagemagick's pdf security policy problem. So in order to work properly just one line in the script needs to be modified like below.


--- scanimage $Verbose -d 'smfp:net;'$SCANNER_IP --resolution $DPI --page-format $ScanSize --format jpeg |
 convert $COLOR - "$FileName"
+++ scanimage $Verbose -d 'smfp:net;'$SCANNER_IP --resolution $DPI --page-format $ScanSize --format ${FileType,,[A-Z]} --output-file "$FileName"

Repository Information Legal Contact Alternative Drivers