Solved

Bash: /script_name Permission denied

Posted on 2004-08-31
11
728 Views
Last Modified: 2006-11-17
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?


0
Comment
Question by:rqs
11 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 11948733
type in:

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

when you run:
./my_script.cgi

the script should be under the current dir, otherwise, you need to do:
/path-to/my_script.cgi
0
 
LVL 2

Author Comment

by:rqs
ID: 11949184
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?
0
 
LVL 38

Expert Comment

by:yuzh
ID: 11949242
It is strange!

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

#!/bin/bash
echo "Hello"
exit

If you can run the above script, please post the 1st line of my_script.cgi
0
 
LVL 2

Author Comment

by:rqs
ID: 11949473
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.
0
 
LVL 38

Expert Comment

by:yuzh
ID: 11949523
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?
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 11

Expert Comment

by:avizit
ID: 11949899
type

which bash
and see if bash is present and also that its present at /bin/bash
0
 
LVL 2

Author Comment

by:rqs
ID: 11950022
which bash points to /bin/bash
bash is indeed present in /bin/bash...
0
 
LVL 20

Expert Comment

by:Gns
ID: 11954304
Fun.
Could you quote the exact script (the nonworking one you've typed in) from above _verbatim_ here... like

---------------------
script
---------------------

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
0
 
LVL 2

Expert Comment

by:sneeuw_chan
ID: 11955848
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'.)
0
 
LVL 1

Accepted Solution

by:
cheail earned 125 total points
ID: 11960039
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
0
 
LVL 2

Author Comment

by:rqs
ID: 11960426
Mounted and unmounted the filesystem and changed setting on fstab.
That did it. my scripts now run.
Thanks Michael =)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now