Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 17 Jun 2019, 04:53
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
Running Bash script in terminal automatically- Solved
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [6 Posts]  
Author Message
wimpy


Joined: 22 Aug 2012
Posts: 406
Location: Essex, UK

PostPosted: Thu 10 Aug 2017, 07:29    Post subject:  Running Bash script in terminal automatically- Solved  

I have a bash script which needs to run in a terminal. If i try running it from a desktop icon, I get the window saying "this looks like a shell script" and it gives some buttons for choices, which include one for running it in a terminal window. I want to bypass this interactive window and automatically launch it from the desktop icon into a terminal. I can do this in Lubuntu, because its desktop icons have a .desktop associated file, which can be tailored to do this. I've thought of compiling the script (using shc), but I'm having difficulty in persuading shc to complete the compilation. I would be grateful for any help or advice.
_________________
LxXenial16.08, LxPupSc17.07.01,Lucid 5.2.8 and others - all frugal

Last edited by wimpy on Thu 10 Aug 2017, 11:17; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1842
Location: Japan

PostPosted: Thu 10 Aug 2017, 08:02    Post subject:  

Assuming that these are ROX desktop icons, right click and select "Edit Item".
Below example will run myscript.sh in a urxvt console when clicking the desktop icon. Adapt to your needs.
run_terminal_script_from_desktopicon.png
 Description   
 Filesize   14.95 KB
 Viewed   216 Time(s)

run_terminal_script_from_desktopicon.png

Back to top
View user's profile Send private message 
wimpy


Joined: 22 Aug 2012
Posts: 406
Location: Essex, UK

PostPosted: Thu 10 Aug 2017, 08:33    Post subject:  

Thanks for the reply. Unfortunately, they are not ROX desktop icons. The icon comes from a drag-and-drop in LxXenial16.08 and right-clicking produces a different set of options. In fact the code I was trying to compile was
Code:

!#/bin/sh
lxterminal -e foo.sh

I was hoping that as the desktop icon would relate to a binary it would bypass the interactive window and run foo.sh in a terminal window.

_________________
LxXenial16.08, LxPupSc17.07.01,Lucid 5.2.8 and others - all frugal
Back to top
View user's profile Send private message 
foxpup


Joined: 29 Jul 2016
Posts: 846
Location: europa near northsea

PostPosted: Thu 10 Aug 2017, 09:45    Post subject:  

wimpy wrote:
Thanks for the reply. Unfortunately, they are not ROX desktop icons. The icon comes from a drag-and-drop in LxXenial16.08 and right-clicking produces a different set of options.


I guess that you drag-and dropped the file foo.sh to your desktop and what you have on your desktop is in fact a link to foo.sh.

What are the set of options you get?
- it might be that you get an option to choose the app to run it with. If you have that option, you can type (at the bottom )
defaultterminal "$@"

- another possibility is to make a real .desktop: http://puppylinux.org/wikka/AppsDesktop
Just copy a ramdom.desktop inside /usr/share/applications/ and change or delete the lines inside. You can open it as text (with geany). Your exec line should look like
Exec=urxvt -e path_to_foo.sh/foo.sh
(I am not entirely sure about that: could be 'Exec=urxvt -e sh path_to_foo.sh/foo.sh' or without -e, just try/Edit: look at next post of mostly_lurking).
Then drag-and-drop the .desktop your created to you desktop. And click it.

Last edited by foxpup on Thu 10 Aug 2017, 10:21; edited 2 times in total
Back to top
View user's profile Send private message 
mostly_lurking

Joined: 25 Jun 2014
Posts: 321

PostPosted: Thu 10 Aug 2017, 09:57    Post subject:  

I guess you could just make a .desktop file and drag-n-drop that onto the desktop.

Either one of the following works, at least on my system:
Code:
[Desktop Entry]
Name=Test
Exec=/root/test.sh
Terminal=true
Type=Application

Code:
[Desktop Entry]
Name=Test
Exec=urxvt -e /root/test.sh
Type=Application


Edit: foxpup beat me to it Smile
Back to top
View user's profile Send private message 
wimpy


Joined: 22 Aug 2012
Posts: 406
Location: Essex, UK

PostPosted: Thu 10 Aug 2017, 11:16    Post subject:  

My thanks to everybody who helped. Creating the desktop entry did it - a la mostly_lurking's second example. I'll mark this as "Solved".
_________________
LxXenial16.08, LxPupSc17.07.01,Lucid 5.2.8 and others - all frugal
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [6 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0328s ][ Queries: 12 (0.0064s) ][ GZIP on ]