#Double clicking to open a .sh file

32 messages · Page 1 of 1 (latest)

merry silo
#

I've created a script called update.sh on my desktop with the following code:


# Define color variables
GREEN='\033[0;32m'
NC='\033[0m' # No Color (reset to default)

# Update system using pacman
echo -e "${GREEN}Running sudo pacman -Syu...${NC}"
sudo pacman -Syu

# Update system using yay
echo -e "${GREEN}Running yay -Syu...${NC}"
yay -Syu

# Update Flatpak apps
echo -e "${GREEN}Running flatpak update...${NC}"
flatpak update

When I open my terminal emulator (Konsole), and enter Desktop/updates.sh, it will run the script properly, however, if I double click the icon, it doesn't do anything.
I've set the script to open with Konsole (shown in the screenshot), but even still, it doesn't open.
When looking online, all I see is people saying I need to run chmod +x Desktop/updates.sh to make it executable. which I have already done.
Thanks in advance for any help. I am new to Arch Linux, so sorry if this is a silly question.

whole plover
#

Could you show us the output of ls -l for the file?

merry silo
whole plover
#

Yeah that shouldn’t be a problem, although you probably don’t want Others to have executable permissions (chmod 774)

Could you try putting set -x at the start of your script?

whole plover
#

Also as far as I’m aware (and depending on your configuration) Yay also checks official repositories, so having -Syu for both pacman and yay is redundant; if you’re trying to update AUR packages only with that second command you can use yay -a or similar

old grottoBOT
#

whiteawake received a thank you cookie!

whole plover
merry silo
whole plover
#

When you try to run it by launching from the file itself, does it open a blank terminal window, or nothing happens at all? I tried it myself and it’s opening the terminal but with no output

#

My only other suggestion is you could try making a .desktop file that links to the script and see if that works

So, for example, you would create a script.desktop file in ~/.local/share/applications/ that contains:

Name=My Script
Exec=konsole -e /path/to/your/script.sh
Terminal=true 
Type=Application```
merry silo
whole plover
#

Possibly a dumb question if you’re using Konsole, but you’re using Plasma, right?

merry silo
#

Yes

whole plover
#

And what file explorer do you use?

merry silo
#

Dolphin

whole plover
#

I’m just wondering if your initial chmod +x is even going through or not

whole plover
# merry silo Dolphin

Right, so could you right‐click the shell file and go to the permissions tab, and see if the box is ticked for “Allow executing file as program”

whole plover
#

Only other thing I can think of is the encoding differs with what the system allows, could you show the output of file /home/yf/Desktop/updates.sh

merry silo
whole plover
#

Yeah that’s all fine

#

Sorry I’m not coming up with any solutions

#

You could try replacing the line in your .desktop file with Exec=/bin/bash /home/yf/Desktop/updates.sh

merry silo
old grottoBOT
#

whiteawake received a thank you cookie!

whole plover
#

I’m also curious as to the solution now since I can’t get it to work either!

#

I do vaguely remember reading some forum posts a long time ago about other KDE users with similar issues

broken compass
#

@merry silo running yay is the same as running yay -Syu which is the same as running pacman -Syu, yay will update native packages, and aur packages