Running Bash script in terminal automatically- Solved
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.
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
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
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.
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
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
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.
Code: Select all
!#/bin/sh
lxterminal -e foo.sh
LxXenial16.08, LxPupSc17.07.01,Lucid 5.2.8 and others - all frugal
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.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.
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.
-
- Posts: 328
- Joined: Wed 25 Jun 2014, 20:31
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:
Edit: foxpup beat me to it
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