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.

kudos, that totally works for the simple hello world script no problem. Finally!

So using the same structure applied to the actual program start script I am trying to run, it runs but gives an error.

~/raw/bioxtasraw ~
/home/dusty/raw/LinuxLib/start_raw: line 4: python: command not found

When I run my other one that opens that directory where I have to then type start_raw in the prompt I notice a couple differences. One is via that route I have (base) which is to do with miniconda and I notice there is a reference to both directories. The one the start script is in for the program, and also the one where the python program code is in.

(base) dusty@X:~/raw/LinuxLib$ start_raw
~/raw/bioxtasraw ~/raw/LinuxLib

And that line 4 of the start_raw script is… python RAW.py

So thank you, you for sure helped me with a great step forward in a small thing. Now I just have to figure out why tilix is opening differently via your suggestion. I am sure the solution is obvious and I am too tired to see it at the moment. Im guessing the other way it is running the contents of my bashrc with the conda contents and this way it is not. That’s my best guess.

I’ve been running too long on 3 hours sleep.

Yes, I am certainly having some misfires in the gray matter, lol.

I tried this with the same results.

Exec=x-terminal-emulator -e /home/dusty/raw/LinuxLib/hello_world.sh

Works in the same manner as what you gave me to try. Runs that script just fine but the other is also the same with the error on line 4. I can’t tell you why your suggestion made that line above finally pop out of my head to try. Would have been nice to have thought of that days ago, lol.

Ugg I’ve been away so many years it’s like starting over. But it is a little worse than being pure rank beginner when you know that you used to know some of this and grasp some concepts but you just can’t recall it.