How do I create a shortcut to a command?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

How do I create a shortcut to a command?

Postby Imagus on Tue Aug 28, 2007 2:42 pm

Hello,

I have succesfully downloaded and installed an online chess program called "jin". After unpacking the file in a separate directory, I tried to start the program by clicking on "jin", but that didn't work - even though the included readme file told me to do it this way. The only way I can get the program to work is by opening a terminal in the jin directory, and then type: java -jar jin.jar

How do I create a shortcut on my desktop that will automatically run this command when I click on it?

Thanks for helping an absolute beginner.
User avatar
Imagus
Level 3
Level 3
 
Posts: 118
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Linux Mint is funded by ads and donations.
 

Postby nick on Tue Aug 28, 2007 3:48 pm

Hi

Right Click on desktop/create launcher, under command put
java -jar jin.jar, check the box marked "run in terminal"

Name-"whatever you want"

Click on icon box to choose icon.

Nick
nick
Level 5
Level 5
 
Posts: 686
Joined: Sat Dec 02, 2006 8:04 am

Postby Imagus on Tue Aug 28, 2007 4:39 pm

Thanks for your reply. Unfortunately it doesn't work, I keep getting an error message when I click the launcher. If I try the command as Application, I get this error:

There was an error launching the application
Details: Failed to execute child process "/media/
sdb1/Linux/jin" (No such file or directory)

And when I try it as Application in Terminal, I get this:

There was an error creating the child process for this terminal

I also tried to change the command from just "jin" to "jin.jar" and even "java -jar jin.jar", but that didn't help either. :cry:
User avatar
Imagus
Level 3
Level 3
 
Posts: 118
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Postby Boo on Tue Aug 28, 2007 9:18 pm

sounds like you do not have write permission to /media/sdb1/Linux/jin.

did you cd into the jin directory and run the command?
it worked that way before.

could you post the output of

ls -l /media/sdb1/Linux/jin

did you unpack the program as yourself or with a sudo ?

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
Boo
Level 8
Level 8
 
Posts: 2364
Joined: Mon Mar 26, 2007 7:48 am

Postby Imagus on Wed Aug 29, 2007 4:47 am

Boo wrote:sounds like you do not have write permission to /media/sdb1/Linux/jin.

did you cd into the jin directory and run the command?
it worked that way before.

could you post the output of

ls -l /media/sdb1/Linux/jin

did you unpack the program as yourself or with a sudo ?

:D



I have entered the command you suggested and I got this:

luc@luc-desktop:~$ ls -l /media/sdb1/Linux/jin chess/jin-2.14.1/jin
ls: /media/sdb1/Linux/jin: No such file or directory
ls: chess/jin-2.14.1/jin: No such file or directory

This looked like it was caused by the space in the directory name, so I renamed it to jinchess without the space, and then tried again. This time I got:

luc@luc-desktop:~$ ls -l /media/sdb1/Linux/jinchess/jin-2.14.1/jin
-rwxrwxrwx 1 root luc 668 2007-08-01 23:03 /media/sdb1/Linux/jinchess/jin-2.14.1/jin

I have no idea what the ls-command does, but at least it seemed to do something. So I also removed the space from the command in the launcher and... it works!

I never would have thought it would be this simple... Gosh, I feel such a newbie...

Anyway, thank you for your help!
User avatar
Imagus
Level 3
Level 3
 
Posts: 118
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Postby scorp123 on Wed Aug 29, 2007 1:12 pm

Imagus wrote: I have no idea what the ls-command does
The manual is your friend.
Code: Select all
man ls

LS(1) User Commands LS(1)

NAME
ls - list directory contents

SYNOPSIS
ls [OPTION]... [FILE]...

DESCRIPTION
List information about the FILEs (the current directory by default).
...
...
User avatar
scorp123
Level 8
Level 8
 
Posts: 2287
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Postby Boo on Wed Aug 29, 2007 11:28 pm

FYI
spaces in Linux/Unix have meaning.
I avoid putting spaces in file and directory names.

if there is a space in a file/dir name you have 2 options:
put the whole path in quotes
or
dereference the space with a backslash.

eg for you origional ls you could have done:
ls -l "/media/sdb1/Linux/jin chess/jin-2.14.1/jin"
or
ls -l /media/sdb1/Linux/jin\ chess/jin-2.14.1/jin

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
Boo
Level 8
Level 8
 
Posts: 2364
Joined: Mon Mar 26, 2007 7:48 am

Postby Imagus on Thu Aug 30, 2007 1:34 pm

Thank you all for the replies. Unfortunately this has turned into a very annoying problem: the launcher only works until I restart my computer! I have tried it several times now, but every time I restart my computer, I need to create a whole new launcher! Even the chess icon has disappeared when Mint starts, all I get is this small white rectangle instead. And when I click that I get the same message as before: "There was an error creating the child process for this terminal".

Why is this? The program is still at its original location and when I create a new launcher everything works great again? I really don't get this...
User avatar
Imagus
Level 3
Level 3
 
Posts: 118
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Postby scorp123 on Thu Aug 30, 2007 2:26 pm

Boo wrote: I avoid putting spaces in file and directory names.
A wise choice. 8)

Boo wrote: if there is a space in a file/dir name you have 2 options:
put the whole path in quotes
or
dereference the space with a backslash.

eg for you origional ls you could have done:
ls -l "/media/sdb1/Linux/jin chess/jin-2.14.1/jin"
or
ls -l /media/sdb1/Linux/jin\ chess/jin-2.14.1/jin
Absolutely correct. Just a minor addition which I put here in the hope that it will benefit others who maybe don't know it: The thing with the backslashes is sometimes called "to escape ..." in some texts. So if someone writes "you have to escape the spaces in the file name" ==> he means that you should convert the empty space in a file name from " " into "\ " (as in Boo's second example above). The backslash here serves as "escape" signal and tells UNIX-like shells "OK, whatever weird character follows after the backslash -- just ignore it please and take it 'as is' ..."

Sometimes it can happen that you come across a file that has 'illegal' characters in its name from a UNIX shell point of view. e.g. files that start with dashes or question marks can be difficult to get rid of again (because both signs have their special meanings in shell programming and thus get interpreted in special ways). So putting the entire thing into quotation marks (Boo's first example above) or by placing backslashes in the right places (Boo's second example) you can avoid troubles and e.g. access and manipulate the file although the shell doesn't really like the filename.
User avatar
scorp123
Level 8
Level 8
 
Posts: 2287
Joined: Sat Dec 02, 2006 4:19 pm
Location: Switzerland

Postby Boo on Thu Aug 30, 2007 9:29 pm

delete the launcher and create a new one with the correct path to the application.

I suspect that when you changed the path in the launcher it does not really save it. some funny bug.

:D
Image
Now where was i going? Oh yes, crazy!
User avatar
Boo
Level 8
Level 8
 
Posts: 2364
Joined: Mon Mar 26, 2007 7:48 am

Postby Imagus on Fri Aug 31, 2007 6:47 am

Hi,

I did create a new launcher, but the problem doesn't go away. Here is what I get after creating a new icon:

Image

... and here is what I get immediately after rebooting:

Image

As you can see, the path in the launcher properties has changed after reboot: sdb1 suddenly became sda1. When I change it back to sdb1 everything's fine again - although I have to manually put back the icon.

What is causing this change? Is this a bug in Mint? Does it have something to do with my hard disks?

Thank you,
User avatar
Imagus
Level 3
Level 3
 
Posts: 118
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Postby Husse on Fri Aug 31, 2007 7:07 am

both sda1 and sdb1 are large FAT32 volumes if I read your screenshot correctly. This may cause problems, but you should not have a change from sda to sdb. However sometimes programs (including an OS) are too smart for their own good.
Do you have a folder called Linux on sda1 as well? Could explain it
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19710
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Postby Imagus on Fri Aug 31, 2007 10:47 am

I have two internal (40 and 320 Gb) and two external hard disks (320 and 250 Gb). The external hard disks are always connected to the computer, so every partition is always available to both Windows and Linux. I only have one folder named Linux, and it's always on the same partition (external hd 2, partition 1), so I assume the path in the launcher should always point to sdb1. I will try to move my Linux folder to another partition on hda or hdb to see if that helps.
User avatar
Imagus
Level 3
Level 3
 
Posts: 118
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: eanfrid, pp4mnkmint and 27 guests