LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 03-28-2003, 05:52 PM   #1
jpantone
LQ Newbie
 
Registered: Mar 2003
Location: Poway, CA (San Diego)
Distribution: Fedora Core 5
Posts: 19

Rep: Reputation: 0
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?
 
Old 03-29-2003, 01:58 AM   #2
rootboy
Member
 
Registered: Oct 2001
Distribution: Mint 15
Posts: 770

Rep: Reputation: 51
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
 
Old 03-29-2003, 10:08 AM   #3
jpantone
LQ Newbie
 
Registered: Mar 2003
Location: Poway, CA (San Diego)
Distribution: Fedora Core 5
Posts: 19

Original Poster
Rep: Reputation: 0
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
 
Old 08-14-2003, 08:17 PM   #4
obarney
LQ Newbie
 
Registered: May 2003
Location: down the street on the right
Posts: 15

Rep: Reputation: 0
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.
 
Old 08-17-2003, 05:36 PM   #5
son_goku02
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Rep: Reputation: 0
i had the same error with an ext3 fs
 
Old 08-19-2003, 04:30 PM   #6
son_goku02
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Rep: Reputation: 0
SOLUTION!!!

for people who are interestet:

add in /etc/fstab in the options section in the line of the specific device:

exec
 
Old 08-19-2003, 09:10 PM   #7
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
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.
 
Old 10-13-2003, 03:51 PM   #8
georged
LQ Newbie
 
Registered: Oct 2003
Location: PST
Posts: 1

Rep: Reputation: 0
Talking 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.
 
Old 10-25-2003, 08:26 AM   #9
marsanu
LQ Newbie
 
Registered: Oct 2003
Location: Ulm, Germany
Posts: 1

Rep: Reputation: 0
Thumbs up

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
 
Old 09-16-2004, 09:36 PM   #10
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: Debian, Ubuntu
Posts: 400

Rep: Reputation: 39
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

Code:
bash ./script2
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
 
Old 09-17-2004, 07:47 AM   #11
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
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
 
Old 09-17-2004, 07:53 AM   #12
DaveQB
Member
 
Registered: Oct 2003
Location: Sydney, Australia.
Distribution: Debian, Ubuntu
Posts: 400

Rep: Reputation: 39
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
 
Old 10-30-2004, 12:39 PM   #13
Fjor
LQ Newbie
 
Registered: Oct 2004
Location: Jalisco, Mexico
Distribution: Slackware
Posts: 24

Rep: Reputation: 5
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
 
Old 11-13-2004, 01:56 PM   #14
jkabs
LQ Newbie
 
Registered: Nov 2004
Location: wisconsin, usa
Distribution: mandrake linux
Posts: 1

Rep: Reputation: 0
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.

 
Old 11-21-2004, 09:39 AM   #15
Dcrusoe
Member
 
Registered: Oct 2004
Location: San Diego
Distribution: Mandrake Linux 10.1
Posts: 30

Rep: Reputation: 15
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/bin/sh: bad interpreter: Permission denied itsaso Linux - Newbie 6 05-18-2005 10:00 AM
: bad interpreter: Permission denied LinuxRam Linux - Newbie 2 08-22-2004 09:33 PM
/bin/sh: bad interpreter: Permission denied linmix Linux - Software 12 08-16-2004 06:40 AM
bash: ./ms-stop: bad interpreter: Permission denied thamarsol Linux - Software 14 05-19-2003 05:15 PM
perl: bad interpreter: Permission denied bulliver Linux - Software 4 01-27-2003 03:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration