4

So I tried making a desktop shortcut which executes a very simple shell script. But when i double click/right click->execute it, it does nothing. (or at least I think it does nothing)

heres how my shortcut and shell script looks: Note the shortcut has "Terminal" set to 1, and i hope that means that it opens the shell script in a new terminal window.. (i have a couple terminals already open, which arent ready for usage (have scripts running))

Shortcut:

[Desktop Entry]
Version=1.0
Type=Application
Name=Test
Comment=Test
Exec=/home/(myusername)/test/test.sh
Icon=utilities-terminal
Terminal=true
StartupNotify=false
GenericName=Test

Shell Script:

#!/bin/sh
# (I tried both, /bin/bash and /bin/sh)
echo "hi"
RolandiXor
  • 51,797

2 Answers2

6

Both the desktop entry and the shell script should have executable permissions. Do:

$ chmod +x path_to_shortcut/shortcut.desktop
$ chmod +x path_to_script/test.sh  

Another way to change permissions for a script is to right click it, go to Properties > Premissions and check Allow executing file as program.

Permissions

ignite
  • 9,044
0

Just in case someone comes here from google search... In 14.04 it's been a pain in the rear to execute shell script which starts Android Studio for me on the mounted drive. Tried numerous things but nothing worked for me. Eventually had to write below code and compile with:

gcc -o studio studio.c 

and then create a shortcut to "studio" from the desktop and now it finally works as it should.

Here is the sample code, you can replace path (/media/.../studio.sh) in that system call after /bin/sh. Make sure it's a full path and leave "/bin/sh " in front.

#include <stdio.h>
int main(void) {
  int ret = system("/bin/sh /media/jeneag/APPS/linux/android-studio/bin/studio.sh");
  printf("app ret code: %d\n", ret);
  return 0;
}
Jenya G
  • 101