Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

bad interpreter: Operation not permitted on Lion 10.7.3

My unix scripts are now dead, after the upgrade to 10.7.3. A typical error message is /bin/bash: bad interpreter: Operation not permitted Googling this issue shows other people are having build scripts fail and are fixing this by renaming links to libraries. My scripts are simple, they just run an executable, or used to... something like this:

#! /bin/bash

./myprogram << EOF

$1

EOF

MacPlus, SE30, iMacG3, EmacG4, PB G4, iMacG5, PowerMacG5, iMac Intel, Mac OS X (10.7.2)

Posted on Feb 13, 2012 10:07 AM

Reply
72 replies

Feb 14, 2012 7:51 PM in response to galfenol

I created a script in TextEdit. This is the result:


Pandora:bin jdaniel$ ls -@Oel hw.sh

-rwxr--r--@ 1 jdaniel admin - 30 14 Feb 22:39 hw.sh

com.apple.TextEncoding 15

com.apple.quarantine 23

Pandora:bin jdaniel$ ./hw.sh

Hello, World


Maybe the problem is your group. I created a standard user account and could finally reproduce your problem by using TextEdit, but not in my normal admin account.

Feb 15, 2012 6:46 AM in response to etresoft

Well I have two 10.7.3 systems, an iMac and MacBook ad they both do it:



admac:Desktop frank$ cat foo.sh

#!/bin/bash

echo script

admac:Desktop frank$ ls -l@ foo.sh

-rwxr--r--@ 1 frank admin 24 Feb 15 09:38 foo.sh*

com.apple.TextEncoding 15

com.apple.quarantine 23

admac:Desktop frank$ ./foo.sh

-bash: ./foo.sh: /bin/bash: bad interpreter: Operation not permitted




Just to be certain you are on 10.7.3? I ask because your profile shows 10.7.2.


One other thing you don't have quarantining disabled on your system?

Feb 15, 2012 9:41 AM in response to Frank Caggiano

I am on 10.7.3. I also get the bad interpreter error when I create a new standard account. I do not get the error in my normal, admin account. Obviously something in my environment is disabling the check. I haven't disabled quarantine as far as I know. I try to keep the system as close to default as possible. However, I do have a few customizations.

Feb 21, 2012 3:12 PM in response to galfenol

I too have been having the same issue, only I think there is something else going on here. I tried editing an ubber-simple Perl script using both TextEdit and VI (actually VIM on the Mac). Both exhibit the same issues with the bad interpreter. I have seen the same behavior when bringing such scripts saved on Windows platforms into a UNIX environment because the Windows editors add the newline character at the end of every line. (Manifests as ^M when viewed in VI; but that does nothing in VIM! So, I tried creating an identical looking script in VIM and saving is right from the Terminal window. After CHMOD to set the execute bits, it ran fine. If I opened the same file in TextEdit.app and added but a single space into the file and saved, the same script was broken again! So next I tried running the now corrupted script through a SED filter, thus:


sed -e "s/^M//g" badscript.pl > goodscript.pl


Run a CHMOD again on goodscript.pl and viola, it now works! This process is repeatable. Thus I believe that TextEdit.app is placing HIDDEN ^M's into the file, and seems to lack an option or Preferences setting to reveal them to us. (Pure VI on UNIX will do this for you, whereas "cat" or "more" command will reveal NOTHING!


I would like to know if someone else here can corrobreate this - or even refute it. I will be glad to hear that it is something other than what I've proposed here. Good dialog though, and a lot of interesting ideas.

Feb 21, 2012 7:01 PM in response to jim505

TextWrangler and Vim will preserve the line ending style of the file it is editing.


TextWrangler -> Edit -> Document Options... allows changing the line ending style. You want to select Unix, as the "Mac (CR)" option is for the Mac Classic OS, not Mac OS X.


In Vim, you can change from DOS to Unix style line ending using


:set ff=unix

Mar 27, 2012 2:51 PM in response to galfenol

Is this the sort of bug Apple are likely to fix? Or are bugs like this not considered that important. After all it's only affecting people accessing Unix or doing things above and beyond web browsing; sending e-mail and watching TV/videos and listening to music.


I came across the bug tonight when trying to do something with EXIFTOOL, having previously modified my script in textedit, as I do from time to time.


I created a brand new file to try and avoid this and then I did the following:

sudo chmod 7777 'name of file' in terminal. However that then simply caused the Operation not permitted error when I then tried to run the script.


A quick and simple task then takes over an hour as I read up on the issue and read the different ways of trying to avoid it or get round it.


I don't do much script writing so I don't see the point of a delicated script editor but I may have no choice if I want an easier life for the time being,


I did wonder what else I've quarantined without realising . I guess it doesn't matter until I hit a problem accessing a file or doing anything with it.


Kind regards

bad interpreter: Operation not permitted on Lion 10.7.3

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.