You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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
Question marked as Top-ranking reply

Posted on Nov 9, 2012 3:21 PM

anticro wrote:


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>

thank u so mutch, your solution work and save my time, and of cource i completely agree with u: about 4 pages of useless spam

72 replies
Question marked as Top-ranking reply

Nov 9, 2012 3:21 PM in response to anticro

anticro wrote:


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>

thank u so mutch, your solution work and save my time, and of cource i completely agree with u: about 4 pages of useless spam

Feb 14, 2012 10:27 AM in response to galfenol

See this TextEdit quarantines files its been reported since 10.7.3 came out.


Google textedit quarantine you'll get a bunch of hits.



However, there appears to be a bug in the latest version of OS X Lion in which the quarantine flag is attached to existing files on the system, preventing some code such as user scripts from being executed. If you create shell scripts, for instance, then opening them in TextEdit and making changes to them will result in them no longer being executable and will result in an "Operation not permitted" error in the Terminal.



from http://reviews.cnet.com/8301-13727_7-57374676-263/workarounds-for-quarantine-bug -in-os-x-lion/

Feb 13, 2012 6:08 PM in response to Linc Davis

Something like this, where the shell script is fistofdeath.sh.

The script has been made executable with chmod +x, or at least this used to work.



bash-3.2$ ls -@Oel ./fistofdeath.sh

-rwxr-xr-x@ 1 galfenol staff - 37 Feb 12 10:37 ./fistofdeath.sh

com.apple.FinderInfo 32

com.apple.ResourceFork 63127

com.apple.TextEncoding 15

com.apple.quarantine 23

bash-3.2$

Feb 14, 2012 8:06 AM in response to Frank Caggiano

csh example fails, as below:


galfenol% more test.sh

#!/bin/csh

echo csh


galfenol% ./test.sh

./test.sh: Operation not permitted.


galfneol% ls -@Oel test.sh

-rwxr-xr-x@ 1 galfenol galfenol - 19 14 Feb 11:40 test.sh

com.apple.TextEncoding 15

com.apple.quarantine 23


I see the script just typed is for some reason quarantined.


One of my scripts that continues to work as always does not return this same quarantine message, but instead:


galfenol% ls -@Oel works.sh

-rwxr-xr-x@ 1 galfenol galfenol - 37 8 Apr 2011 works.sh

com.apple.FinderInfo 32

com.apple.ResourceFork 6073

com.apple.TextEncoding 15

Feb 14, 2012 8:52 AM in response to galfenol

When you ran the find to remove the exteneded attributes you reported that it ran overnight but dodn;t chage anything. Did it remove the quarantine attribute from the scripts?


if you create a script, check to see if the quaritine attribute is set on it and then run


xattr -d com.apple.quarantine
scriptname.sh


does it remove it and does it now run?

Feb 14, 2012 9:46 AM in response to Frank Caggiano

As you suggested,

removing the quarantine with


xattr -d com.apple.quarantine
scriptname.sh


brings these dead bash scripts back to life and now they run, as always.


So how did they get quarantined? Is this a new "feature" of 10.7.3.


If I create a new bash script in TextEdit, and then list it:


bash-3.2$ more test.sh

#! /bin/bash

echo "Today's date is $(date)"


it is immediately quarantined.


bash-3.2$ ls -@Oel test.sh

-rw-r--r--@ 1 purcell purcell - 48 14 Feb 13:38 test.sh

com.apple.TextEncoding 15

com.apple.quarantine 23


If I now make it executable,


bash-3.2$ chmod +x test.sh


and try to run it, it fails as we have been seeing all along:


bash-3.2$ ./test.sh

bash: ./test.sh: /bin/bash: bad interpreter: Operation not permitted


But the xattr

command you gave above, fixes this.


bash-3.2$ xattr -d com.apple.quarantine test.sh

bash-3.2$ ./test.sh

Today's date is Tue 14 Feb 2012 13:46:18 AST


And it stays fixed.


Thank you very much, Frank.

Thanks not so much, Apple.

Feb 14, 2012 10:09 AM in response to galfenol

Well you (we) still have a problem. This happens to me if I write a script in textedit.


First is why the find command Linc gave you and you said ran over night didn;t clear the quarantine bit.


And second why this is happening. I never used textedit to create scripts I use at the command line so I just tried it on a 10.7.3 system. Sure enough the bit was set. and I get the same error you get. If I make the script in emacs it's fine.


I just picked up what the other folks in the thread started. If the find command had worked and cleared the quarantine bit we wouldn't have gotten this far.


Just tried TextWrangler, it works fine. The quarantine bit was not set on the script I wrote and saved from it. So it seems to be a TextEdit problem.


regards

Feb 14, 2012 10:19 AM in response to galfenol

Permission repairs ONLY looks at standard Mac OS X components as well as some apps installed via an installer script that includes a recipt specifying the correct permissions. Your scripts are not included.


I would look at the parent directory to see if it has an inheritance ACL


/bin/ls -dleO@ .

-OR-

/bin/ls -dleO@ /path/to/the/directory/where/you/created/your/script

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 Account.