Ubuntu technical problems and solutions reference, a modern cookbook.
Calling shell script from Unity Launcher
December 2, 2011Posted by on
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 interact
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.