I'm new in linux. I'm try to mount and umount .iso with nemo-script. I put the script /home/user/.gnome2/nemo-scripts/
. My problem is, with gksudo I only run 1 command like su. Who I can run all this script like su?
#!/bin/bash
gksudo -k /bin/echo "got r00t?"
BNAME=$(basename "$NEMO_SCRIPT_SELECTED_FILE_PATHS")
sudo mkdir "/media/$BNAME"
zenity --info --title "ISO Mounter" --text "$BNAME e $NEMO_SCRIPT_SELECTED_FILE_PATHS"
if sudo mount -o loop -t iso9660 $NEMO_SCRIPT_SELECTED_FILE_PATHS "/media/$BNAME"
then
if zenity --question --title "ISO Mounter" --text "$BNAME Successfully Mounted. Open Volume?"
then
nemo /media/$BNAME --no-desktop
fi
exit 0
else
sudo rmdir "/media/$BNAME"
zenity --error --title "ISO Mounter" --text "Cannot mount $BNAME!"
exit 1
fi
Thanks!!
There are a couple of ways to do this. In your script above, you can execute the entire script with
root
permission if you call the scripts itself withsu -c script
orsudo script
. Before doing this, edit your script and remove the calls togksudo
andsudo
. Then at the top of your script add a test to insure the script is run with an effective root UID. E.g.:Then just make sure you run your script as
sudo scriptname
orsu -c scriptname
. Additionally, make sure you have the execute bit set of your script file permissions. You can do it simply withchmod 0775 scriptname
which will giveowner
andgroup
read-write-execute permissions and giveworld
read-execute permissions. If you don't want it world executable, then justchmod 0774
.If you don't set execute permission on your script, you will get a
Permission denied
orcommand not found
error. You can execute the script by specifying the shell in yoursudo
orsu
call, e.g.sudo bash scriptname
orsu -c "bash scriptname"
, but it is preferred to make the script executable.