Ubuntu Technical

Ubuntu technical problems and solutions reference, a modern cookbook.

Calling shell script from Unity Launcher

I have already written in the past a post regarding how to create a custom unity launcher.
Yesterday, I’ve come across an issue. I’ve downloaded Pentaho’s Data Integration tool Kettle, and the executable is a shell script. Meaning that it needs to be called from a terminal in order to run. Now, even though I’ve added the shell script into a Unity Launcher, the software didn’t start after pressing the icon in the dash.
So, I figured out that I need to create another shell script which calls the gnome-terminal and passes the call to the kettle shell script.
In order to achieve this, I used expect (install)

So, I’ve created a script called call_tool.sh:

#!/usr/bin/expect -f

# Get a Bash shell
spawn -noecho bash

# Wait for a prompt
expect "$ "

# Send the dir to kettle and then send the command for spoon.
send "cd /path to script\n"
send "./spoon.sh\n"

# Hand over control to the user

The \n character is needed for the enter.

After that I’ve made the script executable:

sudo chmod +x call_tool.sh

Then pointed my Unity launcher to call_tool.sh, and that’s it. It works.

Flattr this


5 responses to “Calling shell script from Unity Launcher

  1. K March 10, 2012 at 6:18 pm

    Great! This is awesome. Ok, so once you have the launcher, how do you get certain files to open up with that program? For example, I created a launcher to open up texmacs. Now I want all files with the .tm extension to open up with texmacs by default when double clicking.

  2. Patrick December 5, 2012 at 6:21 pm

    Yeah, this really helped. Now I do not need to start my application from the terminal!

  3. Leola January 16, 2013 at 3:37 am

    This is my first time pay a visit at here
    and i am actually happy to read everthing at alone place.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: