This is a static archive of the old Zorin Forum.

The information below may be outdated. Visit the new Zorin Forum here ›

If you have registered on the old forum, you will need to create an account on the new forum.

[SOLVED] script not executing in shortcut key

quenyan

Sat May 02, 2020 9:07:37 am

I'm pretty sure I made no mistakes in making a shell script.
I tried to make a sample.sh script like this
Code:
#!/bin/bash
echo -n "hello world"


with sudo chmod +x, this file now should be executable. it execute just fine in terminal. but when I execute it by clicking the script, the terminal open and close after 0.025 secs which is i dont know why.

I want to embed it to a key shortcut.. please help.
I want to make this script
Code:
echo -n "test123" | xsel -b

this script is like a simple clipboard thing

=========
SOLUTION
=========

:!: use "exit" or "read" at the end of the bash script
:!: caution: if you are executing the script from shortcut key, do not use "./path/to/script.sh", instead use "sh /path/to/script.sh"
:idea: If you just wanted to execute it from the terminal using command "./<script_name>.sh", then you dont need the "exit" or "read" command. my feeling telling me that ubuntu designed to prevent script from running if there is no "end" contained in a script when executing it from the file manager or shortcut key

Swarfendor437

Sat May 02, 2020 11:41:01 am

Hi, please be patient - I don't write scripts - but perhaps someone else does on here? ;) :D

quenyan

Sat May 02, 2020 1:41:47 pm

I remember seeing option [ ] Run this on Terminal. on some of ubuntu distros

quenyan

Mon May 04, 2020 3:09:19 am

i found out what the problem is....silly me, not having much understanding about scripting in ubuntu based OS. the script won't run if I dont put "exit" or "read" at the end of the bash script, I thought it just happen in Zorin, but I also tried in another ubuntu OS too. thank you for visiting my post :D

btw, scripting in puppy linux is much easier, we don't need to put "exit" or "read" after the list of commands, it just run (silently, with no terminal popping up and dissapear). :idea:

Swarfendor437

Mon May 04, 2020 4:45:29 pm

Sadly I was just getting use to CLI on my Amiga 1500 when my first Windows 95 machine arrived - and I stupidly got hooked on a game! :D

quenyan

Mon May 04, 2020 5:20:05 pm

Swarfendor437 wrote:Sadly I was just getting use to CLI on my Amiga 1500 when my first Windows 95 machine arrived - and I stupidly got hooked on a game! :D

thats super old man... :o