Simple script - execute command on selected file

Posted by askmoo on Ask Ubuntu See other posts from Ask Ubuntu or by askmoo
Published on 2011-06-23T08:59:59Z Indexed on 2011/06/23 16:32 UTC
Read the original article Hit count: 204

Filed under:

I want to make a script that will execute .jar file on selected file. Later I will add that script to right-click menu via the tool Nautilus Actions or just place it into nautilus-scripts folder. I have a problem creating script.

When I am in a usual console screen and want to execute this jar file on any other file, I use this syntax

myfile.jar ./someotherfile.xml

and the jar file will write the output to the console screen.

So I created a file script.sh, added lines in it

#!/bin/bash
/home/username/myfile.jar $1

But it does not output anything. I know I am doing something wrong. Please help.

To sum, I need a script that will use selected file as a parameter, open the gnome-terminal, inside that terminal it will start JAR file and pass it the selected file.

I am confident that this is a very simple procedure, but I am total newbie with shell scripting.

© Ask Ubuntu or respective owner

Related posts about shell-scripting