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

Apr 9, 2012 11:46 PM in response to galfenol

I just figured out why i was getting the output -bash: ./hello.sh: bin/bash: bad interpreter: Operation not permitted when trying to compile a simple script Hello World.


To fix it i had to go to the TextEdit file that I saved as hello.sh and right click, select Get Info and go to select Open with drop down menu and choose and select Open with: TextEdit.


The script run perfectly afterwards.


Please let me know if this also worked for you? If not I can try and advise further.

Apr 10, 2012 5:07 AM in response to anthon9969

yeah... this is something to do with the changes for Gatekeeper I think. I noticed if I save and double click to run files from TextEdit I've gotten prompts saying "TextEdit downloaded this from the internet, are you sure you want to run it" stuff... I'm like... no I just wrote that, it wasn't downloaded... but it doesn't do it all the time.

Apr 10, 2012 6:48 AM in response to doh1231

doh1231 wrote:


I just ran into this problem too... only happens with TextEdit and I've used it for years to edit scripts.

Don't do that. TextEdit is for documents, not UNIX scripts.


yeah... this is something to do with the changes for Gatekeeper I think. I noticed if I save and double click to run files from TextEdit I've gotten prompts saying "TextEdit downloaded this from the internet, are you sure you want to run it" stuff... I'm like... no I just wrote that, it wasn't downloaded... but it doesn't do it all the time.

It has nothing to do with Gatekeeper. That is only in Mountain Lion. If you are working with UNIX scripts, you don't use TextEdit and you don't double-click.

Apr 10, 2012 10:50 AM in response to etresoft

First, don't push your preferences on other people like its some type of right or wrong. I've done quick editing of simple scripts in TextEdit for many years and its never been a problem.... its a text editor after all. Just because you do not like doing that, or it has some features to do more than that doesn't mean it cannot do that. I was adding what I've seen and what is the issue, not asking for anyone's opinion if its the way things should be done.


And yes Gatekeeper is on 10.7.3, including changes to the quarantine system that is causing this issue. I know Gatekeeper cannot be seen in preferences and its disabled by default, but the changes for it is what I'm talking about. If you want to enable Gatekeeper on 10.7.3 you have to use the command line, but it is there.

Apr 10, 2012 1:38 PM in response to doh1231

doh1231 wrote:


First, don't push your preferences on other people like its some type of right or wrong. I've done quick editing of simple scripts in TextEdit for many years and its never been a problem.... its a text editor after all.


TextEdit is a rich text editor that is using the NSDocument system. That is not appropriate for a script text editor. It has too much overhead. The way it saves files is not appropriate for scripting because it will assign extended attributes and arbitrarily reset permission.


And yes Gatekeeper is on 10.7.3, including changes to the quarantine system that is causing this issue. I know Gatekeeper cannot be seen in preferences and its disabled by default, but the changes for it is what I'm talking about. If you want to enable Gatekeeper on 10.7.3 you have to use the command line, but it is there.


That's all well and good, but nobody else has these problems with a true text editor. I don't even have these problems using TextEdit. If you start hacking around on new command line scripts that aren't done yet, all bets are off.

Apr 12, 2012 11:46 AM in response to etresoft

I generally use the tool that is handy and simplest to use. I'm not always in Terminal (thankfully) and I have often used TextEdit to create/edit scripts. It works for me, but I also recognise the features of TextWrangler and use it as well. I was somewhat disappointed when it went to the Apple store and the download from there broke authenticated saves, so I went back to Text Edit for a while. The current version of TextWrangler works well though.


I'm not sure what the point of the whole "do this. don't do that." thing is here. Use the tool that works for you. If it fails, try a different tool.


By the way, vi/vim are a pain if you just want to write simple scripts. I recognize the additional features as potentially awesome (if you can find how to use them) but for simple scripting it really is over kill. Time would tell, naturally, whether commiting to vi/vim would pay off for every/any individual scripter.


There is another command line text editing tool available that is a bit friendlier and way simpler. nano. Give it a try if you haven't. You may find it is the gateway drug that pushes your to vi/vim. 😉

Apr 20, 2012 8:40 AM in response to galfenol

All these answers are useless spam! The only thing that says what's really going on and a solution that works is described here:


http://stackoverflow.com/questions/9952612/mac-os-usr-bin-env-bad-interpreter-op eration-not-permitted


Short: run this command and you should be fine.

xattr -d com.apple.quarantine <YOUR FILE HERE>


Moderators should delete alle the spam in here.


Apr 20, 2012 9:04 AM in response to anticro

What you have provided was already pointed up by Frank Caggiano, and is a solution for 1 file (and arguably, a group of files) but you offer nothing in regard to preventing it in the first place, and you managed to insult everyone who HAS offered a solution to the problem occuring in the firt place.


Pluses and minuses are nearly equal. Maybe YOU could post without the attitude?

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.