[Solved] Cant run sh script by double clicking on it

… but running it manually (copy paste into terminal line by line) works

New to Endeavor and relatively new to Arch world and generally to Linux world

I have set one partition with Manjaro, another with Endeavor, everything is the same, both fresh installs, only running one old win32 game on them, since I havent figure out yet, how to run it on my Debian based OS. Game works fine on both. But I can’t seem to figure out, how to run ‘sh’ script by doubleclicking on it, on Endeavour. The same script runs ok on Manjaro. This is script:

#! /bin/bash

cd /home/mx/Desktop/Ruun/
conda activate myvenv
python myapp.py

If I open the terminal and run script line by line, all goes well:
(running python virtual environment ‘myvenv’ and inside running program ‘myapp.py’)

Script is owned by me, and it is executable. Everything is the same as on Manjaro. Interestingly, i have another script, that opens the terminal and starts another script that runs the game, that script works fine, by doubleclicking on it with the mouse. Working script:

#! /bin/bash

xfce4-terminal & ./launcher.sh run

Anyone happens to know what may be the sollution? I have 15 scripts that need to run these virt environments 3 at a time and it is time consuming running them one line at a time.

Sys info although probably not needed and I’m on manjaro at this time.
Well just in case:

System: Kernel: 5.13.19-2-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 Desktop: Xfce 4.16.0
Distro: Manjaro Linux base: Arch Linux
Machine: Type: Desktop System: Hewlett-Packard product: HP Compaq 6200 Pro MT PC v: N/A serial:
Mobo: Hewlett-Packard model: 1497 serial: UEFI: Hewlett-Packard v: J01 v02.15
date: 11/10/2011
Battery: Device-1: hidpp_battery_0 model: Logitech Wireless Mouse B330/M330/M331
charge: 55% (should be ignored) status: Discharging
CPU: Info: Quad Core model: Intel Core i7-2600 bits: 64 type: MT MCP arch: Sandy Bridge rev: 7 cache:
L2: 8 MiB
flags: avx lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 54310
Speed: 2630 MHz min/max: 1600/3800 MHz Core speeds (MHz): 1: 2630 2: 2217 3: 3345 4: 1835 5: 2477
6: 2415 7: 2398 8: 2521
Graphics: Device-1: AMD Lexa PRO [Radeon 540/540X/550/550X / RX 540X/550/550X] vendor: Sapphire Limited
driver: amdgpu v: kernel bus-ID: 01:00.0
Display: x11 server: X.Org 1.20.13 driver: loaded: amdgpu,ati unloaded: modesetting
resolution: 1680x1050~60Hz
OpenGL: renderer: Radeon RX550/550 Series (POLARIS12 DRM 3.41.0 5.13.19-2-MANJARO LLVM 12.0.1)
v: 4.6 Mesa 21.2.2 direct render: Yes
Audio: Device-1: Intel 6 Series/C200 Series Family High Definition Audio vendor: Hewlett-Packard
driver: snd_hda_intel v: kernel bus-ID: 00:1b.0
Device-2: AMD Baffin HDMI/DP Audio [Radeon RX 550 640SP / RX 560/560X] vendor: Sapphire Limited
driver: snd_hda_intel v: kernel bus-ID: 01:00.1
Sound Server-1: ALSA v: k5.13.19-2-MANJARO running: yes
Sound Server-2: JACK v: 1.9.19 running: no
Sound Server-3: PulseAudio v: 15.0 running: yes
Sound Server-4: PipeWire v: 0.3.37 running: no
Network: Device-1: Intel 82579LM Gigabit Network vendor: Hewlett-Packard driver: e1000e v: kernel port: f040
bus-ID: 00:19.0
IF: eno1 state: down mac:
Device-2: Intel 82540EM Gigabit Ethernet driver: e1000 v: kernel port: d000 bus-ID: 06:00.0
IF: enp6s0 state: up speed: 1000 Mbps duplex: full mac:
Drives: Local Storage: total: 495.01 GiB used: 15.96 GiB (3.2%)
ID-1: /dev/sda vendor: Seagate model: ST500DM002-1BD142 size: 465.76 GiB
ID-2: /dev/sdb type: USB vendor: SanDisk model: Cruzer Blade size: 29.25 GiB
Partition: ID-1: / size: 57.84 GiB used: 15.75 GiB (27.2%) fs: ext4 dev: /dev/sda4
Swap: Alert: No swap data was found.
Sensors: System Temperatures: cpu: 39.0 C mobo: N/A gpu: amdgpu temp: 48.0 C
Fan Speeds (RPM): N/A gpu: amdgpu fan: 1072
Info: Processes: 249 Uptime: 1d 1h 42m Memory: 7.73 GiB used: 3.54 GiB (45.8%) Init: systemd Compilers:
gcc: N/A Packages: 1080 Shell: Bash v: 5.1.8 inxi: 3.3.06

Can you list the command you used to make it executable?

2 Likes

I’m not sure if double clicking the script actually runs it :thinking:

What works without fail for me is to run it from the terminal.

chmod +x script.sh
./script.sh
1 Like

Welcome to the forum @former :partying_face: :tada: :balloon: :enos_flag:

1 Like

Imposed “security” is a PITA, a quick internet search:

thunar -q
xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default --create --type bool --set true

Tried to test, but I run Wayland.

1 Like

EDIT: ran your command and it worked, thank you very much!

As relative new to the Linux I’m using GUI where I can :slight_smile: I right clicked on the script → properties, permissions and allowed it to be executable. I did same on Manjaro. Since in both OS user is the same, I also tried and copied these two scripts from Manjaro. Same thing, only one liner works by doubleclicking on it.

One liner, that works on both:

-rwxr-xr-x 1 mx mx 54 Jul 20 07:13 start1.sh

Three liner that (doubleclicking on it) only works on Manjaro:

-rwxr-xr-x 1 mx mx 78 Jun 10 07:03 Ruun.sh

That did it, thank you very much!!!
What exactly does it means, what this command do and how did you figure it out? Something to do with Conda’s virtual environment? Or Python specifically?

Nope, running scripts in thunar has been disabled by the nanny state for your safety. That command turns it back on. To reverse change to false (oops).

:safety_vest:

1 Like

Yes, double clicking on it runs it :slight_smile:

Other command is:
bash script.sh

Thank you :slight_smile:

I see. Interesting, doubleclicking script on desktop actually means running it inside Thunar… didn’t know this. probably something to do with virtual environment, since the one liner worked out of the box.
Thanks again.

EDIT: got it solved, see my last post: Cant run sh script by double clicking on it - #14 by former

My bad, I was running Manjaro when I ran your command, so naturally, it worked and I though my problem is solved.

I ran script this way in terminal: ./myscript.sh and got this error:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

Followed by python trace error, which tells me virtual environment is not being started.

So, now I know, script does starts! There is something between bash and conda that it is not working as it should.

My first thought was, I have some problem with conda. But since running commands one line at a time works, conda is set properly and virtual environment works. So there is some kind of problem in relation between bash and conda.

I will try tese things:

1 - I will create new virtual environment under miniconda and try again
2 - I will create new virtual environment using only Python, without miniconda
3 - If 1 and 2 fails, I will uninstall and install miniconda again

I will come back and report. If anyone has any other suggestion, I’m all ears :wink:

I don’t know how/where to initialize conda init
I tried by adding this line into the script:
conda init bash

Like so: (I’m assuming Endeavour uses Bash, like Manjaro?)


cd /home/mx/Desktop/Ruun/
conda init bash
conda activate takp38
python nparse.py```

But didn't make any difference. There is some difference between Manjaro and Endeavour, how conda/miniconda interact with bash.

This did the trick!

I created new python’s built in virtual environment, and script now runs and everything executes as it should, so my problem is solved.

I would rather use condas virtual environment, since that way I can set which python version to use and it does not changes. Python’s built in venv uses systems python. When it changes with the system, this can potentially in the future cause python script to stop working (the one I’m running through the bash script). But I will worry about this when it happens. For now everything works, that’s all that matters right now :smiley:

https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment


One setting may be useful to you when using conda init is:

auto_activate_base: bool
This setting controls whether or not conda activates your base environment when it first starts up.

1 Like

I would say with your python/bash scripting knowledge, which is already more than many beginners on linux, I am surprised by this.

Hopefully you will give the terminal a go and realize how much faster you can communicate directly with your system. For example you can make your scripts executable and add them to your path. Then open terminal type one custom word and press enter, et voila!

Up to you when and what you like to learn, EOS is terminal centric in nature, so it’s time to open that terminal and

sudo pacman -Syu

And of course you wouldn’t run blindly a command but read the wiki :wink:

https://discovery.endeavouros.com/pacman/pacman-basic-commands/2021/03/

1 Like

Well, it is all in the details. :wink: By bash knowledge is close to 0. Took me lots of inet-fu to get them working. My python scripting knowledge is very low. I know few basic commands and I know how to set up virt. environments. I was forced to learn if I wanted to start using others peoples scripts. Python script I’m running is of course not mine.

About GUI - I’m an old, senior, with bad memory. I use terminal here and there. I have huge text file cheat sheet. (for example, which is it, “sudo update-grub” or “sudo grub-update”? I can never remember! Lets check cheat sheet!) Which is few hundreds lines long. Takes time to find the darn thing in that cheat sheet. Or I can, if is an option, use mouse or mouse right click. Much faster. On my main, my Thunar has configured custom action for a LOT of things: ownership to user, ownership to root, compress images, remove digital footprints in images… things like this. Right click beats searching through cheat sheet big time.

This reminds me, I’m always surprised, how good, experienced and long time Linux users, like to point out to their ‘clean desktop’ for example. I can never understand that. You cant see anything on that desktop but wallpaper. To run something, you need to open some kind of search, type in keyword, choose thing from the menu… these are many steps. My (main, Debian based) desktop is cluttered, icons and shortcuts everywhere! Horror for some :wink: lol But I know where they are. Every important folder has it’s shortcut. Most used documents have their own desktop shortcuts. Most of things I need, I can get access to with a one single mouse click. My guess is, it beats previously mentioned steps when using clean desktop. For sure in my case.

I understand what you are saying. But look at mine case. Right now, I have around 15 different folders I run that script from. So 15 different Icons and all I need to do is to just click on one of them. Or I could, like you said, open the terminal, type in one of 15 different custom words I need to remember first, (each for different script folder destination) to run them. Mouse/icon is in this, my case, much easier and faster. I LOVE my icon shortcuts lol lol lol, they makes my life easier.

I only use EOS & Manjaro to run this one win32 app that I can’t get it to work for now on my main os, MX.

Oh, and I do use: sudo pacman -Syu :grinning_face_with_smiling_eyes:

Actually from Manjaro I’ve learned, as a good practice, to first switch to console (Ctrl+Alt+F4), before updating the system. Can sometimes help, when GUI also gets updated. Is it the same here on EOS? Guide didn’t mention it.

And (ta-da) I’ve read Pacman basic commands and few other guides after install of EOS :wink: You guys have some nice guides! And good distro!

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.