Run in Terminal option not working? (scripts)

I have created some scripts to run. Let’s just discuss everyone’s first script, the hello world script. It’s created correctly, I can open Tilix, call it and it executes fine.

But it is 2020, who wants to have to do that for all scripts right? So I double click them in the GUI DE and select run or run in terminal. It doesn’t work.

Why?

I have complied some code for my daughter to run. For her it needs to just have an icon to click and it works instead of having to open a terminal and call the script to run the programming.

Have you given the script file execute permissions?

At the top of the script have you told it which shell to use?

e.g. #!/bin/bash

Be careful with spaces in the script filename - suggest use _ characters

Yeah the scripts and file names are all good. And they are set to execute. They run no problem if I open Tilix and command them to run.

What I can’t figure out is if I click them graphically and chose run or run in terminal they don’t run? Not even the simple hello world will run if I click run in terminal. Should that not open Tilix and run the script?

have you got an example script you can share please?

Not even this will run by clicking run in terminal

#!/bin/bash
# declare STRING variable
STRING="Hello World"
#print variable on a screen
echo $STRING

But it does if I open Tilix and call it to run by command line myself.

at the end of your script I added read -p "press enter to continue"

Then I created a .desktop file on my desktop with the contents

[Desktop Entry]
Name=Run My script
Icon=trayicon
Exec=/home/dad/Desktop/example.sh
Terminal=true
Type=Application
Categories=GTK;GNOME;Application;Utility;

That displays in a terminal waiting for you to press enter to continue

1 Like

I think I have done the same as you other than of course my path and file name is different, but correct, same thing. Here is what I understood you to do with the script.

#!/bin/bash
# declare STRING variable
STRING="Hello World"
#print variable on a screen
echo $STRING
read -p "press enter to continue"

And here is my desktop icon

[Desktop Entry]
Name=Run My script
Icon=trayicon
Exec=/home/dusty/raw/LinuxLib/hello_world.sh
Terminal=true
Type=Application
Categories=GTK;GNOME;Application;Utility;

I of course set both to executable. When I click the icon nothing happens.

When I run it in tilix it is fine.

~/raw/LinuxLib$ ./hello_world.sh
Hello World
press enter to continue

This is my first experience with tilix. Is this something specific to tilix where I am trying to do something that doesn’t play?

It seems like the only way I can get a desktop icon to open tilix is…

Exec=tilix

And so it will open but it won’t run anything I add beyond that. The only thing I have been able to add to that line that works is

Exec=tilix --working-directory=/home/dusty/raw/LinuxLib

Then it opens tilix in the directory my script is in and I can type the command to run it and it runs.

Very confused lol. Of course ultimately I am trying to get a desktop icon to run tilix and open a script in the same directory so I created the hello world one there to see if it was something wrong with their script to start their software. I am now wondering if it is something to do with me having (base) on the far left of my tilix prompt since installing miniconda that was needed for this software?

(base) dusty@

This is in my bashrc which is what I think causes the (base) dusty@ in my tilix prompt.
I don’t know if this is what is road blocking me but if so I don’t know why they would have bothered with desktop icons that won’t work.

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/dusty/miniconda2/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/dusty/miniconda2/etc/profile.d/conda.sh" ]; then
        . "/home/dusty/miniconda2/etc/profile.d/conda.sh"
    else
        export PATH="/home/dusty/miniconda2/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

I just did the same from a Pearl OS live usb and it worked fine?
(Pearl Desktop 7.1 ~ 18.04 base)


Did the same with my Ubuntu Budgie 19.10 live usb to see if it was miniconda related and it don’t work.

Then I thought maybe something is missing/broke as far as having tilix both launch and run a script for this from a desktop icon so I installed gnome terminal and tried to change the default terminal. But changing it doesn’t do anything. So I couldn’t test that theory. I will have to see if I have a Ubuntu 19.10 Gnome usb stick to try it on.

Had to send my kid back to college with a desktop icon with…

Exec=tilix --working-directory=/home/user/raw/LinuxLib

…which opens tilix and goes to the directory, so she is in the right directory to type a command that opens her RAW software she is using at college for science stuff.

Tested via Ubuntu Budgie 18.04 LTS live usb

Does not work.

Tested via Ubuntu Mate 18.04 LTS live usb, works fine in Mate Desktop with Mate Terminal.

I’m very confused. Can anyone help here?

Try this:
Desktop file:

[Desktop Entry]
Name=Run My script
Icon=trayicon
Exec=tilix -e bash -c /home/rob/Desktop/test.sh
Terminal=true
Type=Application
Categories=GTK;GNOME;Application;Utility;

I will try that tonight.