Wednesday, May 22, 2013

Scanner SMB Access

The company has a networked scanner which is configured to save scanned PDF documents on a MS Windows SMB share.

Hooking up from a Linux machine requires a domain name, user name, password and mount operation.   I need to scan things maybe once a month, so I don't want to bother with a permanent connection.

Here is a simple little script to handle this share on Fedora.  The script uses Zenity and Beesu to make it a little more user friendly.  You should replace the IP address of the scanner, YOURDOMAIN and myusername with your credentials.  You should also create the mount point /mnt/scan.
#! /bin/bash
pass=$(zenity --entry --title="Add an Entry" --text="WindowsPassword:" --entry-text "password" --hide-text)
beesu - mount -t cifs -o domain=YOURDOMAIN,username=myusername,password=$pass,rw,file_mode=0777,dir_mode=0777 // /mnt/scan
nautilus /mnt/scan
beesu - umount /mnt/scan

The rw, file_mode and dir_mode parameters ensure that while root does the mounting, a common user will get read and write access to the mounted share.

This script will ask for your Windows and Root passwords, mount the share and open a Nautilus file browser.  You can then do what you want and when you close Nautilus, it will unmount the share.

Another upshot of this is that if you have a virtual machine with Windows 7 Home edition, which Microsoft deliberately crippled so that it cannot access Domain services, then all you need to do is mount the share with Linux and then use Virtualbox Devices, Shared Folders, to connect to it!

La voila!

No comments:

Post a Comment

On topic comments are welcome. Junk will be deleted.