LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2005, 03:26 PM   #1
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Rep: Reputation: 49
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
 
Old 10-05-2005, 03:34 PM   #2
free_ouyo
Member
 
Registered: Mar 2004
Location: Belgium
Distribution: Ubuntu
Posts: 133

Rep: Reputation: 15
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
 
Old 10-05-2005, 03:38 PM   #3
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
Thanks will try and let you know
 
Old 10-05-2005, 04:07 PM   #4
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
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.
 
Old 10-06-2005, 02:14 AM   #5
free_ouyo
Member
 
Registered: Mar 2004
Location: Belgium
Distribution: Ubuntu
Posts: 133

Rep: Reputation: 15
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
 
Old 10-06-2005, 02:41 AM   #6
kushalkoolwal
Senior Member
 
Registered: Feb 2004
Location: Middle of nowhere
Distribution: Debian Squeeze
Posts: 1,249

Original Poster
Rep: Reputation: 49
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
 
Old 08-16-2008, 01:45 PM   #7
AVT
LQ Newbie
 
Registered: Aug 2008
Posts: 10

Rep: Reputation: 0
Is there another way to do this if you're not using GNOME?

I'm using xfce.
 
Old 08-16-2008, 06:17 PM   #8
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170
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.
 
Old 06-05-2010, 03:10 AM   #9
iqbal.shirol
LQ Newbie
 
Registered: Jun 2010
Posts: 5

Rep: Reputation: 1
Smile 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.
 
Old 11-24-2010, 04:42 PM   #10
mozillanerd
LQ Newbie
 
Registered: Jul 2010
Location: Fountain Valley, CA, USA
Distribution: ubuntu, fedora
Posts: 7

Rep: Reputation: 0
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/
 
Old 11-24-2010, 04:47 PM   #11
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
@AVT,
It's the same. R click on the panel> Add item> Launcher, and away you go.
 
Old 11-25-2010, 01:25 PM   #12
mozillanerd
LQ Newbie
 
Registered: Jul 2010
Location: Fountain Valley, CA, USA
Distribution: ubuntu, fedora
Posts: 7

Rep: Reputation: 0
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.
 
Old 11-25-2010, 02:29 PM   #13
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by mozillanerd View Post
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.
 
Old 11-25-2010, 02:30 PM   #14
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Kenhelm View Post
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.
 
Old 11-26-2010, 03:27 PM   #15
mozillanerd
LQ Newbie
 
Registered: Jul 2010
Location: Fountain Valley, CA, USA
Distribution: ubuntu, fedora
Posts: 7

Rep: Reputation: 0
Question Need execute permissions on vfat volumes when they automount

Quote:
Originally Posted by Sergei Steshenko View Post
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to execute a shell script in GUI by double click kamesh156 Programming 1 10-18-2005 05:25 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 12:33 AM
executing shell script on apache nooodles Linux - General 1 06-29-2004 01:51 AM
How to get Konqueror to execute shell scripts in a new console on double click nitrambass Mandriva 0 06-22-2004 10:38 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 09:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration