[SOLVED] bash scripts not running on LMDE

Archived topics about LMDE 1 and LMDE 2
Locked
midden

[SOLVED] bash scripts not running on LMDE

Post by midden »

I recently switched from Linux Mint Maya to LMDE.
I am used to running bash scripts by calling them directly:
myscript.sh:

Code: Select all

#!/bin/bash
echo "Hello World!"
Change permissions, but running the script fails:

Code: Select all

$ chmod +x myscript.sh
$ ./myscript.sh
bash: ./myscript.sh: Permission denied
So I have to call bash directly for it to run:

Code: Select all

$ bash ./myscript.sh
Hello World!
How do I get the behavior I am used to (i.e., running scripts without calling bash directly)?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
jdhedden

Re: bash scripts not running on LMDE

Post by jdhedden »

You need the execute bit set on the directory as well.

Code: Select all

chmod +x .
midden

Re: bash scripts not running on LMDE

Post by midden »

That did not work. The directory already had full rwx access for all users. I suspect this is a weird permissions thing because I just installed LMDE on another machine and I have no issues running scripts. I think this problem is because I had to play around with UID and GID numbers to make my old home directory readable (I am not using it as /home, just symlinking to relevant folders). Any ideas how to track down the source of this?
midden

Re: bash scripts not running on LMDE

Post by midden »

OK, this is weird. In my home directory, I can run scripts and there is normal tab-completion of the file names if I start with "./"

However, if I am in my symlinked directory there is no tab completion and I have to run the file using "$ bash ./myscript.sh"

I am the owner and group for these folders and files, have full rwx access. What is going on here?

(Again, this linked folder is the home directory of another Mint flavor on another partition so there may be some weirdness there)
User avatar
karlchen
Level 23
Level 23
Posts: 18211
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: bash scripts not running on LMDE

Post by karlchen »

Hello, midden.

Could it be that the script which you cannot execute in spite of adding the executable bit is located on a FAT32 or NTFS filesysem, i.e. on a non-Linux filesystem?

Kind regards,
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
midden

Re: bash scripts not running on LMDE

Post by midden »

Ugh... it was a weird fstab issue. Somehow the LMDE was mounting the partition as "user,rw,errors=remount-ro 0 0"

I changed this to "defaults 0 2" and all is well. I _think_ this is because the defaults have the "exec" flag on, but I am not sure. Regardless, I learned something!

Thanks for your help.
Locked

Return to “LMDE Archive”