[ Date Index ][
Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
Thanks for that, I have managed to fix it, for now anyway, but your script is a lot better than mine so i think it's a case of doing a rewrite, and incorporating them together. as you said the script can be expanded, so I want to do that, perhaps incorporate my lower case routine so all the characters are lower case. a few questions 1. with the supermount -i disable, is this session only or permanant? 2. WIth my script I had to change the ownership permissions, should i also need to change the group permissions from root to users? Thanks again Paul
Firstly, are you using something horrible like "supermount"? I know that
Mandrake does by default as of version 8.2 (I think), but I don't know
whether SuSE does too. If it does, and you're not too worried about having
to mount floppies/CDs, etc by hand, then disable it (as root: supermount -i
disable).
Secondly, I would personally have written the script a little differently:
#!/bin/bash
# A QaD script to mount and copy all the images off the camera...
#
# Set the directory to the current date:
varDESTDIR=`date +"%Y%m%d"`
if [ "$UID" -ne 0 ]
then
echo "You need to run as root!"
exit 1
else
echo "Running as root... good!"
if [ -e /dev/sda1 ]
then
mount /dev/sda1 /media/camera
case $? in
0)
echo "Mounted the device OK.";;
1)
echo "Problems mounting the device!"
exit 1;;
esac
else
echo "The camera device (sda1) doesn't seem to exist!"
echo "Please make sure the camera is plugged in..."
read -p "Press <ENTER> to verify the device name:"
fdisk -l | grep -i "sd"
exit 1
fi
echo "Making destination directory."
mkdir /home/pausut/camera/$varDESTDIR
echo "Copying files over..."
cp /media/camera/* /home/pausut/camera/$varDESTDIR/ -va
case $? in
0)
echo "Completed copying files.";;
1)
echo "Error copying files!";;
esac
umount /media/camera
exit 0
fi
#EOF
With any luck, the above would mount the device, make a new directory with
the current date, copy all the files over verbosely, recursively, and
maintaining the permissions (I prefer the -a switch over the -R switch,
personal preference), and unmount the device again. Notice that there's an
"exit 0" at the end whereas I've used "exit 1" on errors. Also note that
you do not need to use "*.*", * will suffice.
To be perfectly honest, scripts like yours and mine can very easily be
extended. For example, after the "fdisk" statement I could have put a bit
to ask for user input for the actual device name (I've not got to grips
with sed/ed yet, so there's no way I would be able to extract the device
name from an fdisk call!) and then have another go at mounting it.
Hope this helps a little.
--
Grant Sewell
BSc (Hons)
Email: grant.sewell@xxxxxxxxxx
Phone: +44 (0) 7866 065964
-- The Mailing List for the Devon & Cornwall LUG Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the message body to unsubscribe.