[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using sudo in a script.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2016-08-03 12:21, Ken Heard wrote:
> I would like to create a short script to mount and unmount SCXC
> cards. For these exfat cards to do either in Jessie has to be done
> as root.
> 
> I have set up sudo so that my user can run any command as root.
> the following command will mount the card without asking for my
> password.
> 
> sudo mount -U 6238-3434 /media/xca
> 
> (My file /etc/fstab contains the following line:
> 
> UUID-6238-3434  /media/xca      exfat   rw,users,noauto,noatime 0
> 0)
> 
> In order to automate the process I wrote the following script named
> mxca :
> 
> #!/bin/bash # Script to mount xca from any directory. CURPWD=$PWD 
> cd /home/ken sudo mount -U 6238-3434 /media/xca cd $CURPWD
> 
> Running mxca alone does not produce the required result.  Running
> sudo mxca together however does, even though the sudo command is
> also in the script.
> 
> I can unmount the card by running command sudo umount /media/xca,
> but I would like a similar script named uxca to do the same thing
> for unmounting.
> 
> Is there a way to make sudo do its thing in these scripts so that
> I can mount and unmount the SDXC card by running the script
> commands mxca and uxca by themselves?

I have since discovered a command "/sbin/mount.fuse" and "fusermount
- -u" which are supposed to allow a non-privileged user to mount and
unmount exfat devices; but I haven't figured out how to use them yet.
 A simple "/sbin/mount.fuse /media/xca" or "fusermount -u /media/xca"
do not work.  Other than fixing the format of the UUID device indicate
from UUID- to UUID= I have yet to experiment with Don Armstrong's
other suggestions.  I thing I would rather get /sbin/mount.fuse and
fusermount -u to work instead.

Regards, Ken


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAleiYSoACgkQlNlJzOkJmTe4fwCcDvq8eBcq0I7guGdmmhN23sgP
3KEAn0LJKJzJUlIJTD0jMMt3T4CyXWAw
=lclv
-----END PGP SIGNATURE-----


Reply to: