Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Im trying to make a shortcut to login my ssh server:

ssh x.x.x.x

I made the following file:

ssh_home.sh

Made it executable:

sudo chmod +x ./ssh_home

Checked by right clicking properties to check if it was executable and it was..

But whatever I do, when double clicking it, it will launch gedit. I tried "Open With" but no terminal app is shown there. I searched the net but only found a way to link to the file while not integrating it in one "shortcut file"

share|improve this question
2  
Did you add #! /usr/bin/sh at the beginning of the file (the first line)? –  Misery May 23 '13 at 11:50
    
Out of interest, what version of Ubuntu are you running? In principle it should be just a case of marking the file as executable in Properties/Permissions, but on 13.04 this seems not to work for me (even directly on the .sh file, with #! /bin/bash at the start...) –  Jez W May 23 '13 at 11:59
    
Also check owner and permissions. Does user clicking it have permission to run it? –  Misery May 23 '13 at 12:04
1  
Your commands can't be correct - You're referring to ssh_home.sh and /ssh_home, which are not the same files. –  l0b0 May 23 '13 at 12:04
1  
@Misery: It's /bin/sh, not /usr/bin/sh. (/usr/bin/sh will happen to work on systems where /bin and /usr/bin are the same directory; I don't think that's the case for Ubuntu>) –  Keith Thompson Jul 10 at 21:05

4 Answers 4

up vote -7 down vote accepted

open a terminal

sh '/home/yourname/Desktop/yourfile'   

or drag and drop it...

share|improve this answer
6  
The question is to get a launcher set up on teh desktop... I dont think the terminal command would help on that front. –  charlie May 23 '13 at 12:21
1  
how on earth an answer with -6 downvotes is accepted as THE answer ? –  Serg Feb 18 at 17:47
1  
@aaaa How does this help make a shell script into a launchabl desktop shortcut?? –  Igor G. Mar 29 at 16:26

I know this is a while ago but though if someone else asks I have this answer.
Open nautilus
Files menu -> behaviour tab
run executable text files when they are opened

In later versions this option is found at: Files menu -> Edit -> Preferences -> behaviour tab

In Ubuntu 14.10 move the mouse to the top of the screen and the File, Edit etc... Menu bar appears. Click EDIT -> Preferences -> Behaviour tab

share|improve this answer
    
Works perfectly, thank you. –  denysonique Oct 2 '13 at 2:57
1  
This should be the accepted answer IMHO. I was getting rather frustrated trying to figure out why I could not run the shell script from Nautilus. –  David Baucum Aug 16 '14 at 0:12
    
What is Files menu? Never seen it. –  Igor G. Mar 29 at 16:27
    
Worked. Right click on my shell script in the file browser. Created link. Then drag and dropped link to desktop. Also did the step above in file browse -> Preferences->run instead of view. –  maxweber Apr 16 at 15:33
    
One complication is that this affects all executable files. (That might be what you want.) –  Keith Thompson Jul 10 at 21:06

I think it would be better to use a launcher file for your script by creating a ~/Desktop/ssh_home.desktop file with the following contents:

[Desktop Entry]  
Version=1.0  
Exec=/home/yourname/bin/ssh_home.sh  
Name=SSH Server  
GenericName=SSH Server  
Comment=Connect to My Server  
Encoding=UTF-8  
Terminal=true  
Type=Application  
Categories=Application;Network;

That way you will have an icon to click which will launch your script.

share|improve this answer
1  
This method IS working but I prefer a 1 file solution... –  michel May 23 '13 at 14:16
3  
@michel If all the script does is run ssh host, you don't need the script, just change the Exec line to Exec=ssh host. –  geirha May 23 '13 at 18:33

The "trap" for me was that I searched via right-clicking on the file for a way to change the behaviour (to have a script run instead of opened in gedit). Don't right-click ! Rather open from the "regular" menu-bar:

Edit-Preferences-Behaviour and change to "run" or "ask each time".

Comment: For my taste there should be a way to run a program via right-clicking too. Especially since right-clicking leads to the menu "open with", which makes you search for "open with bash", however "bash" is not included as an option...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.