Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
03-28-2003, 05:52 PM
|
#1
|
|
LQ Newbie
Registered: Mar 2003
Location: Poway, CA (San Diego)
Distribution: Fedora Core 5
Posts: 19
Rep:
|
Bash: bad interpreter, permission denied
Occasionally, when I attempt to execute a bash script I get:
Bash: Bad interpreter: Permission denied.
Which is odd, since the script is 777 and /bin/bash is 755
Can anyone tell me what's going on here?
|
|
|
|
03-29-2003, 01:58 AM
|
#2
|
|
Member
Registered: Oct 2001
Distribution: Mint 15
Posts: 770
Rep:
|
I would be very curious to see what the first line of the file you were trying to run looked like
For instance, #!/bin/sh would call up the shell that /bin/sh points to (usually bash). However, a non-exsistant shell will give you an error similar to the one the you got (try changing #!/bin/sh to #!/bin/trash to see what I'm talking about).
You can also override these pesky shells by envoking your script like this:
sh ./myproggie
John
|
|
|
|
03-29-2003, 10:08 AM
|
#3
|
|
LQ Newbie
Registered: Mar 2003
Location: Poway, CA (San Diego)
Distribution: Fedora Core 5
Posts: 19
Original Poster
Rep:
|
the first line is
#!/bin/bash
although /bin/sh is a symlink to /bin/bash
/bin/bash is 755
other shell scripts with the same first line work ... usually
|
|
|
|
08-14-2003, 08:17 PM
|
#4
|
|
LQ Newbie
Registered: May 2003
Location: down the street on the right
Posts: 15
Rep:
|
I had this same problem and am embarassed to admit that I just figured out what the problem was. I post it here in the event that someone else searches for the problem like I did.
I was getting "bad interpreter" errors when I tried to execute some scripts via ./scriptname and such. I JUST realized that it only seemed to happen on a certain filesystem. You guessed it ... it was a FAT32 filesystem I had mounted under Linux for file transfer purposes.
Oh well.
|
|
|
|
08-17-2003, 05:36 PM
|
#5
|
|
LQ Newbie
Registered: Aug 2003
Posts: 2
Rep:
|
i had the same error with an ext3 fs
|
|
|
|
08-19-2003, 04:30 PM
|
#6
|
|
LQ Newbie
Registered: Aug 2003
Posts: 2
Rep:
|
SOLUTION!!!
for people who are interestet:
add in /etc/fstab in the options section in the line of the specific device:
exec
|
|
|
|
08-19-2003, 09:10 PM
|
#7
|
|
Member
Registered: Jul 2003
Distribution: Slackware
Posts: 392
Rep:
|
I've also got the bad interpreter error; it was caused because the script had the DOS CR LF character line ending. I had been editing the script in Windows (I know, evil--but at least I was in the cygwin environment).
I used the "od -c" command to diagnose the problem.
I used the "fromdos" command to straighen the problem out.
Lyle
Last edited by lyle_s; 09-05-2003 at 06:46 PM.
|
|
|
|
10-13-2003, 03:51 PM
|
#8
|
|
LQ Newbie
Registered: Oct 2003
Location: PST
Posts: 1
Rep:
|
Bad Interpreter
The cryptic "Bad Interpreter" error message can be generated if a nested shell script does not have execute permission.
For example, you have
two shell scripts, a.sh and b.sh.
a.sh does some stuff then runs b.sh
if b.sh is not executable (chmod a+x) you may get a "Bad Interpreter". One might expect a more enlightening error message such as "no execute permission for subshell". rather than a permission related error.
One way to determine if this is your problem is to use a debugging option for your shell.
For example you can try
"/bin/bash -x a.sh"
This will run a.sh, and display every executed line.
|
|
|
|
10-25-2003, 08:26 AM
|
#9
|
|
LQ Newbie
Registered: Oct 2003
Location: Ulm, Germany
Posts: 1
Rep:
|
Quote:
Originally posted by lyle_s
I've also got the bad interpreter error; it was caused because the script had the DOS CR LF character line ending. I had been editing the script in Windows (I know, evil--but at least I was in the cygwin environment).
I used the "od -c" command to diagnose the problem.
I used the "fromdos" command to straighen the problem out.
Lyle
|
This saved my day! I had the same problem, now everything is working as expected again. Many thanks!!!
Mike
|
|
|
|
09-16-2004, 09:36 PM
|
#10
|
|
Member
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: Debian, Ubuntu
Posts: 400
Rep:
|
Well i have just had the same problem, curiously.
The same script in the same folder on the same partition executing the same commands, works once and then after a reboot for another purpose no workies
Code:
[david@xpbeast packers]$ ./script2
bash: ./script2: /bin/bash: bad interpreter: Permission denied
I got it running using
without a problem.
1) it was in unix file format
2) the partition entry in fstab hadnt changed
3) the shebang was #!/bin/bash
4) it was an executiable file (hence calling bash specifically worked)
5) i tried as root, same response
I got it working, so thats the main thing, but i find it very curious though 
|
|
|
|
09-17-2004, 07:47 AM
|
#11
|
|
Member
Registered: Jul 2003
Distribution: Slackware
Posts: 392
Rep:
|
That's odd. Please post the output of the "mount" command run without arguments, the contents of your /etc/fstab, and which partition your script2 resides on.
I know you said you didn't change anything in /etc/fstab before the reboot, but maybe the reboot isn't the point at which it stopped working, only the point at which you noticed it stopped working.
Lyle
|
|
|
|
09-17-2004, 07:53 AM
|
#12
|
|
Member
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: Debian, Ubuntu
Posts: 400
Rep:
|
Thanx alot for the reply.
I later found (just recently actually) it was a NFS mount. Same name dir with the same named files oops
I thought i had executed scripts before on my NFS mounts, like i installed the system on an NFS mount that has the same arguments as this NFS mount in question.
Oh well, the work around worked fine anyways
Thanx again for the reply, i guess i should  more before posting 
|
|
|
|
10-30-2004, 12:39 PM
|
#13
|
|
LQ Newbie
Registered: Oct 2004
Location: Jalisco, Mexico
Distribution: Slackware
Posts: 24
Rep:
|
Hi! I had the same problem, and the cause was the mounting options for /home.
To enhance security if some user tried to compile and run programs, I added 'noexec,nosuid' to the options for /home in /etc/fstab.
bash, as the which command told me, is /usr/bin/bash, linked in Slackware to /bin/bash which is not on the /home partition, so the command
bash /home/fjor/script
run successfully, but if I do a chmod +x script, I never could run it as ./script or /home/fjor/script, because /home does not allow execute access to files.
I was trapped by my own paranoia but, in a second thinking, that were the behaviour I wanted.
So, if I want now to create user accesible scripts to do maintenance or simplify things like list the names of the users in my server, or find the email of someone, I move the scripts to /usr/local/bin for normal users, or to /usr/local/sbin, for only root access.
I hope this comment has been useful.
Fjor
|
|
|
|
11-13-2004, 01:56 PM
|
#14
|
|
LQ Newbie
Registered: Nov 2004
Location: wisconsin, usa
Distribution: mandrake linux
Posts: 1
Rep:
|
Hi all,
I had exactly the same problem - thanks to all of your postings - I went and added the "exec" directive in my
/etc/fstab file for the specific nfs mount that I was using. On remounting, my scripts ran without any problem.
All the postings were of great help.

|
|
|
|
11-21-2004, 09:39 AM
|
#15
|
|
Member
Registered: Oct 2004
Location: San Diego
Distribution: Mandrake Linux 10.1
Posts: 30
Rep:
|
bad interpreter again
In my case I've the same problem and the solutions given have not worked. I have a simple script:
#! /bin/bash
#
# cpu_hog
#
# Small shell script for displaying top 10 processes.
#
ps -efF | sort -r | head
<-----------end script--------------->
Imported from an AIX Unix where it runs under the #!/bin/ksh korn
I put the script in /usr/bin set 755 and am running as root. Path to /bin/bash is set right in my env and bash scripts from source work but this one doesn't.
Any ideas?
|
|
|
|
All times are GMT -5. The time now is 05:29 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|