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

Using sudo in a script.



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

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?

Regards, Ken Heard


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

iEYEARECAAYFAleiGgQACgkQlNlJzOkJmTeE9ACfaJZ3Fk27+a9YPhHtk040cCpF
D/QAnA7KuGGRMlkP3AIpHqUiTgtyaaq2
=cxii
-----END PGP SIGNATURE-----


Reply to: