LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   executing shell script in terminal directly with a double click (https://www.linuxquestions.org/questions/programming-9/executing-shell-script-in-terminal-directly-with-a-double-click-370091/)

kushalkoolwal 10-05-2005 03:26 PM

executing shell script in terminal directly with a double click
 
Hi,

I have written a shell script named install.sh. I have placed the script on my Debian Desktop. Generally in order to execute this script, we follow these steps:

1.Open a terminal
2. cd /path/to/shellscript
3. type "sh install.sh" to execute

Now, I am trying to automate the entire above process. What I want is that when the user double clicks the shell script on the Desktop with mouse, it should execute in terminal in the usual way.

Also, when I right click on the script and click on 'Open', the GNOME gives me 4 options:
'Run in Terminal'
'Display'
'Cancel'
'Run'

I know that selecting the first option ''Run in Terminal'' looks like a probable option, but I don;t want the trouble of even right clicking on the file. This is because the target users of this script have no knowledge of Linux(assuming).

There fore I want the script to launch the terminal and start executing as soon as the user double clicks on it.

Thanks

free_ouyo 10-05-2005 03:34 PM

executing shell script in terminal directly with a double click
 
Hello,

In Gnome :
- right click on the desktop and 'create launcher'
- browse to the script location and give a name
- don't specify 'run in terminal'
- change the icon to user friendly one

This should work fine.
I think the user must have executable rights on the script.
--
free_ouyo

kushalkoolwal 10-05-2005 03:38 PM

Thanks will try and let you know

kushalkoolwal 10-05-2005 04:07 PM

Re: executing shell script in terminal directly with a double click
 
Quote:

Originally posted by free_ouyo
Hello,

In Gnome :
- right click on the desktop and 'create launcher'
- browse to the script location and give a name
- don't specify 'run in terminal'
- change the icon to user friendly one

This should work fine.
I think the user must have executable rights on the script.
--
free_ouyo

Dude thanks for the idea. It worked but one change. I had to check the box for 'Run in Terminal'. Without that it just won't do anything.

thank you once again.

free_ouyo 10-06-2005 02:14 AM

executing shell script in terminal directly with a double click
 
Hello,
Try to run this little script from custom launcher without 'run in terminal' and take a look at the '/tmp' after running, on my system, it create the file and write the text without having seen something at the screen.

#!/bin/bash
touch /tmp/shortcut.txt
echo "Hello World !" >> /tmp/shortcut.txt

--
free_ouyo

kushalkoolwal 10-06-2005 02:41 AM

Actually if you read my question, I have said that I want to see the terminal screen, but with just a double click on the file. That;s it.

thanks

AVT 08-16-2008 01:45 PM

Is there another way to do this if you're not using GNOME?

I'm using xfce.

Kenhelm 08-16-2008 06:17 PM

I put this at the top of my bash scripts:-
Code:

tty -s; if [ $? -ne 0 ]; then konsole -e "$0"; exit; fi
If the script is not running in a terminal then it restarts itself in Konsole.

iqbal.shirol 06-05-2010 03:10 AM

Re: executing shell script in terminal directly with a double click
 
Hey All,

You can run the shell script by a double-click on it, by following the below steps:

> Create the script and save it in a file.
> Right click on that file.
> Goto 'Open With'
> Goto 'Open With other application
> You can find 'Use a custom command' at the bottom. Click on that.
> Click on 'Browse'
> Select 'gnome-terminal' from the files in the /usr/bin/
> Click on 'Add'
> Then click on 'Close'

Now whenever you double click on that file it will run in the terminal.
And if you want to edit that file, open it with vi editor or right click and select open with any other editor.

Cheers,
Iqbal S.

mozillanerd 11-24-2010 04:42 PM

Execute .sh files in FAT volumes
 
Since Nov 10th, I have not been able to doubleclick to execute a .sh; I can not chmod the file (nothing is changed as `ls -la Pharo.sh` shows.
WHen I create a launcher I get "Permission denied'. This is understandable since the file is not executable.
I have found no way to start my Pharo Smalltalk. Here is the Pharo.sh file:http://pastebin.ubuntu.com/536076/

impert 11-24-2010 04:47 PM

@AVT,
It's the same. R click on the panel> Add item> Launcher, and away you go.

mozillanerd 11-25-2010 01:25 PM

Problem executing .sh file in FAT volume
 
The previous instructions to set up a launcher fails because the file is not executable and I have not found a way to set it executable - either from 'context'->permissions or via chmod.
It is possible to copy the entire smalltalk (pharo version) distribution to a local folder and change the permissions for Pharo.sh and for ../Contents/Linux686/squeak.

Sergei Steshenko 11-25-2010 02:29 PM

Quote:

Originally Posted by mozillanerd (Post 4171057)
The previous instructions to set up a launcher fails because the file is not executable and I have not found a way to set it executable - either from 'context'->permissions or via chmod.
It is possible to copy the entire smalltalk (pharo version) distribution to a local folder and change the permissions for Pharo.sh and for ../Contents/Linux686/squeak.

You have to change your 'mount' setting - FAT32 volumes should be mounted with 'x' permission added by default to all files.

Sergei Steshenko 11-25-2010 02:30 PM

Quote:

Originally Posted by Kenhelm (Post 3250101)
I put this at the top of my bash scripts:-
Code:

tty -s; if [ $? -ne 0 ]; then konsole -e "$0"; exit; fi
If the script is not running in a terminal then it restarts itself in Konsole.

'konsole' is KDE-specific, it may be not installed by default.

mozillanerd 11-26-2010 03:27 PM

Need execute permissions on vfat volumes when they automount
 
Quote:

Originally Posted by Sergei Steshenko (Post 4171089)
You have to change your 'mount' setting - FAT32 volumes should be mounted with 'x' permission added by default to all files.

I would like to know the exact fstab line I need.
I have the following one, and still have a problem doubleclicking on Pharo.sh (a smalltalk startup file):

/dev/sdb1 /home/intrader/windata vfat users,rw,umask=000,dmask=000,fmask=000 0 0

I expect the vfat volume to automount to /home/intrader/windata with execute permissions (ideally only for .sh files).

I don't quite know what to make of your konsole submission - what is it?


All times are GMT -5. The time now is 07:44 PM.