I have a script which does the following:

  1. Connect via sshfs to a directory on a server
  2. Within that directory, there is an encrypted volume. Open it to the device mapper.
  3. Mount to a local directory (-o rw & -t ext4)

When I run this script from the terminal

sudo /.../myscript.sh

it runs with the expected behaviour. However, when I run this script from a desktop shortcut, it runs, but with problems. In particular:

  1. It appears to be mounted, and I can 'cd' into the mounted directory and list the contents. However, when I try to list the contents of a subdirectory, I get this message:

    ls: reading directory .: Input/output error

  2. I don't seem to have write access to the directory. (I can't save files)

My desktop entry looks like this: (... is just for simplicity, again)

[Desktop Entry]
Exec=mate-terminal -e "sudo /.../myscript.sh"

Can anyone suggest why running the script from the shell seems to work, but running from the desktop shortcut gives me problems?

  • It's looks a liitle bit strange Exec=mate-terminal and Terminal=false together. – Costas Feb 12 '15 at 10:59
  • Maybe so, but I have used that combination before with no problems. Also, it's not as though the script doesn't run. – SauceCode Feb 12 '15 at 11:04
  • 2
    The environment this runs from is probably different. Try running env in the scripts to see what is set. If something fails, it should spit out some errors, so redirect stderr to a log file and post the results. – orion Feb 12 '15 at 11:24
  • Thanks for the suggestion. I just tried this. The mount command triggers no output in the log file, either running the script directly or through the desktop entry. I also sent the output of 'env' to the log file. There is no difference except for the presence/absence of the 'LS_COLORS' line and a different path in the SUDO_COMMAND AND OLDPWD entries which I assume are not relevant. – SauceCode Feb 12 '15 at 14:00
  • Doesn't gksudo /.../myscript.sh do everything you want (assuming you're running Gnome)? – Ken Sharp Feb 12 '15 at 14:05

Doesn't gksudo /.../myscript.sh do everything you want (assuming you're running Gnome)? – Ken Sharp

... actually that does seem to work! Looks like this is an example of the mysterious problems mentioned here http://www.psychocats.net/ubuntu/graphicalsudo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.