D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] copying files from a camera. using a shell script



On Saturday 07 August 2004 11:44, paul sutton wrote:
I am trying to write a script to mount my camera which is usb,  I can
access this using mount /dev/sda1 /media/camera
this doing ls -l /media/camera. shows the directory listings fine

my script is as follows

#!/bin/sh
echo "camera mounting and copy routine"
#root check
if [ "$UID" -ne 0 ]
then

      echo "YOU ARE NOT RUNNING AS ROOT"

Don't run it as root in the first place, Paul. Edit your /etc/fstab and allow 
it to be mounted by a user and set noauto. Avoid running anything as root if 
at all possible - there's no reason to use root just to mount known 
filesystems. Your script will only cause problems by creating all the copied 
images as root.root ownership.

      mount /dev/sda1  /media/camera

If you haven't got this in /etc/fstab, you might want to specify a filesystem 
type.

mount: /dev/sda1 is not a valid block device

Use a test condition in the bash script to handle this silently:
if [ ! -d "/mnt/calvin/codehelp" ]
then
       mount /mnt/calvin
fi

if the codehelp directory does not exist below the /mnt/calvin mount point, 
then the filesystem (in this case NFS) is not mounted. Adapt this snippet to 
your system. 

total 0
cp: cannot stat `/media/camera/*.*': No such file or directory
total 0

the first part of this tells me it's not mounted, but I can cd to the
camera fine.

But if you ls /media/camera you get an empty directory - the 
directory /media/camera must exist (hence why you can cd to it) but it is 
empty until the mount operation succeeds.

My mtab file is here,
/dev/sda1 /media/camera vfat rw 0 0

/dev/sda1 /media/camera vfat rw,noauto,user 0 0

I use:
/dev/sda1       /mnt/stick      vfat    rw,user,noauto          0       0
/dev/sdb1       /mnt/disgo      vfat    rw,user,noauto          0       0
/dev/sdc1       /mnt/dazzle     vfat    rw,user,noauto          0       0
in /etc/fstab

What have I done wrong,  I think there is a problem with auto mounting, why
is the mount point so long,  usb-storage etc etc.

Then don't auto mount, use noauto and mount it (and unmount it) manually.


whats going wrong.  and how do i stop it mounting the camera where it does,

noauto

and just have it mount on /dev/sda1 /media/camera. which is much easier. 
it worked fine with suse 9.0

-- 

Neil Williams
=============
http://www.codehelp.co.uk/
http://www.dclug.org.uk/
http://www.isbn.org.uk/
http://sourceforge.net/projects/isbnsearch/

http://www.biglumber.com/x/web?qs=0x8801094A28BCB3E3

Attachment: pgp00005.pgp
Description: signature


Lynx friendly