LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   executing script with ./ does not work (https://www.linuxquestions.org/questions/linux-newbie-8/executing-script-with-does-not-work-444741/)

Lotharster 05-14-2006 02:29 PM

executing script with ./ does not work
 
I wrote a script:
Code:

#!/bin/bash
echo Hello world

when I try to execute it via ./hello, it does not work:
Code:

me@mymachine:~$ ./hello
bash: ./hello: /bin/bash: bad interpreter: Permission denied
me@mymachine:~$ ls -l|grep hello
-rwxr-xr-x  1 lo lo  29 May 14 21:38 hello

I set the right permissions, so what is wrong?

Lotharster

TigerOC 05-14-2006 02:40 PM

Go to the directory where the script is located and do chmod 700 ./hello

BCarey 05-14-2006 02:52 PM

You do not have permission to run bash? Try to check the permissions of bash and chmod as necessary.

Brian

Lotharster 05-14-2006 03:07 PM

Quote:

Originally Posted by BCarey
You do not have permission to run bash? Try to check the permissions of bash and chmod as necessary.
Brian

The bash permissions are:
Code:

-rwxr-xr-x  1 root root 611K Dec 19  2004 /bin/bash
So that should be OK ?

Lotharster

btmiller 05-14-2006 04:02 PM

Very odd -- perhaps you wrote the script on a partition that's been mounted with the noexec flag? Check with the mount command or try moving the hello script to another directory (on a different partition)and run it again. it would help if you told us which distro and version you are using.

Lotharster 05-14-2006 04:53 PM

Quote:

Originally Posted by btmiller
(...) perhaps you wrote the script on a partition that's been mounted with the noexec flag? (...)

I tried moving the script to my $HOME directory, and it worked there. How can i set/unset the noexec flag?
This is the fstab entry of the partition. (It is a loop-aes-encrypted partion.)
Code:

/dev/hda7      /mnt/crypted    ext3    defaults,user,noauto,loop=/dev/loop0,encryption=aes128,itercountk=1000  0      0

btmiller 05-14-2006 05:13 PM

Hmmm ... I don't see noexec in the fstab options. Maybe it's a side effect of it being an encrypted partition. I did a quick Google and didn't find anything relevant. I tried it on a normal, unencrypted loop filesystem and it worked fine. Unfortunately I don't have the necessary encryption built into my kernel to try that.

BCarey 05-14-2006 05:27 PM

What does "loop=/dev/loop0" do? Could this be the source of the permission problem? (My /dev/loop0 is set at 660.)

Also, will the script run as root?

Brian


All times are GMT -5. The time now is 05:41 PM.