Wednesday, March 19, 2008

How To Create A Launcher For A Shell Script

In Linux, you may often find apps that are launched via a script. These are called in the terminal like so:

which is of course nice, when you are in a terminal.

but creating a launcher for such a script is a pain, so here is what I do.

For this example we will pretend we have a shellscript called "shakespear" and it lives in the /home/jim/apps folder. This name is only for our example - you can use any name you like.

Somewhere, such as your home folder, create a file called
edit the file to have the following in it:

#! /bin/bash
cd /home/jim/apps
And save it

Then make that file to executable:

chmod u+x shakespear
Now you can just create a launcher to point to that file, and you are all set. Calling a script from a script may not be the the best way to do it, but it works...


Giorgos said...

thanks !!!
i was looking for that !!!

Anonymous said...

I have been pulling my hair out trying to get a launcher to run a script. I am using Ubuntu Hardy and your suggestion, was the first that I have found that actually worked. Thanks.

Mike said...

Quite helpful! Workarounds for the win =]

Gerald said...

Really cool stuff! Looked for hours to find a solution for this simple hard thing ..

Anonymous said...

Thank you.
Very helpful.

Anonymous said...

Short and sweet. Cheers!!

vova said...
This comment has been removed by the author.
vova said...

Why not simply use a command to combine change of working directory and script execution there -
sh -c "cd directory; ./"
no need for second script.

Anonymous said...

what a genius, i'd been looking for that for years