Running Bash script in terminal automatically- Solved

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
wimpy
Posts: 406
Joined: Wed 22 Aug 2012, 10:30
Location: Essex, UK

Running Bash script in terminal automatically- Solved

#1 Post by wimpy »

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.
Last edited by wimpy on Thu 10 Aug 2017, 15:17, edited 1 time in total.
LxXenial16.08, LxPupSc17.07.01,Lucid 5.2.8 and others - all frugal

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#2 Post by MochiMoppel »

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.
Attachments
run_terminal_script_from_desktopicon.png
(14.95 KiB) Downloaded 315 times

User avatar
wimpy
Posts: 406
Joined: Wed 22 Aug 2012, 10:30
Location: Essex, UK

#3 Post by wimpy »

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: Select all

!#/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

foxpup
Posts: 1132
Joined: Fri 29 Jul 2016, 21:08

#4 Post by foxpup »

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, 14:21, edited 2 times in total.

mostly_lurking
Posts: 328
Joined: Wed 25 Jun 2014, 20:31

#5 Post by mostly_lurking »

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: Select all

[Desktop Entry]
Name=Test
Exec=/root/test.sh
Terminal=true
Type=Application

Code: Select all

[Desktop Entry]
Name=Test
Exec=urxvt -e /root/test.sh
Type=Application
Edit: foxpup beat me to it :)

User avatar
wimpy
Posts: 406
Joined: Wed 22 Aug 2012, 10:30
Location: Essex, UK

#6 Post by wimpy »

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

Post Reply