• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 766
  • Last Modified:

Bash: /script_name Permission denied

The scripts I am referring to are written in Perl and are part of my CGI-based applications.

The execute bit for these files are already set (chmod 755).

I have no problems running them on  another server.

If I do a    perl my_script.cgi ,   no errors from the script are generated.

If I run directly I get permission denied error:

    myshell$ ./my_script.cgi
    bash: ./my_script.cgi: Permission denied

I already checked that the scripts point to the location of perl.

What else could be the problem?

1 Solution
type in:

ls -al my_script.cgi
to check the script permission.

when you run:

the script should be under the current dir, otherwise, you need to do:
rqsAuthor Commented:
the file permission is already -rwxr-xr-x for the said file.
and the current directory i'm in when I run ./my_script.cgi is the location of the file.
What else should I try?
It is strange!

Can you please test to see if you can run this little script:

echo "Hello"

If you can run the above script, please post the 1st line of my_script.cgi
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

rqsAuthor Commented:
Hey, tried the script. still get the same error: Permission denied. =(
Its strange for me and I couldn't think of any
other reason for this error.
Have you made any change to your system?

type in:
echo $SHELL
echo $PATH

and post the output.

Can you try to run the same script as another user?

which bash
and see if bash is present and also that its present at /bin/bash
rqsAuthor Commented:
which bash points to /bin/bash
bash is indeed present in /bin/bash...
Could you quote the exact script (the nonworking one you've typed in) from above _verbatim_ here... like


so that we see there's no strangeness with the first lines "hash-bang" thing (like spurious whitespace or somesuch). Also, what shell/version/distro is this user using?

Could you also try doing
/bin/sh ./myscript.cgi
and (if you have it)
/bin/ash ./myscript.cgi

-- Glenn
I ran a couple tests and the only way I get the error you describe above is when the script doesn't have the executable bit set.  (Or maybe the read bit).  ALthough I must admit having run into this problem myself once, and being stumped for some time as well.  Pity I can't recall what the problem was (might have been the x-bit tho'.)
If the permissions are set 755, and ./my_script generates permissions denied, how is the filesystem mounted?
If the filesystem that ./my_script lives on is mounted noexec, then the interpretor wont allow you to run it directly with ./my_script

- Michael
rqsAuthor Commented:
Mounted and unmounted the filesystem and changed setting on fstab.
That did it. my scripts now run.
Thanks Michael =)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now