galfenol

Q: 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 4:00 PM

Close

Q: bad interpreter: Operation not permitted on Lion 10.7.3

  • All replies
  • Helpful answers

first Previous Page 3 of 5 last Next
  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Feb 14, 2012 10:27 AM in response to galfenol
    Level 7 (25,782 points)
    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/

  • by Linc Davis,

    Linc Davis Linc Davis Feb 14, 2012 11:02 AM in response to galfenol
    Level 10 (207,963 points)
    Applications
    Feb 14, 2012 11:02 AM in response to galfenol

    The solution is simple. Don't use TextEdit to edit scripts.

  • by BobHarris,

    BobHarris BobHarris Feb 14, 2012 11:12 AM in response to Linc Davis
    Level 6 (19,405 points)
    Mac OS X
    Feb 14, 2012 11:12 AM in response to Linc Davis

    I would suggest trying TextWrangler to edit his scripts, assuming he wants a GUI editor.

     

    TextWrangler (free download)

    <http://www.macupdate.com/info.php/id/11009/textwrangler>

     

    PS.  Linc was definitely on the right track to suspect the quarantine attribute as the root cause of the problem.

  • by galfenol,

    galfenol galfenol Feb 14, 2012 4:17 PM in response to Frank Caggiano
    Level 1 (0 points)
    Feb 14, 2012 4:17 PM in response to Frank Caggiano

    Running the find to remove the exteneded attributes did not remove the quarantines from the scripts.

  • by Linc Davis,

    Linc Davis Linc Davis Feb 14, 2012 4:30 PM in response to galfenol
    Level 10 (207,963 points)
    Applications
    Feb 14, 2012 4:30 PM in response to galfenol

    Yes it did. I've tested that command, and it works. When you open the scripts in TextEdit, as we now know, the attribute is restored.

  • by galfenol,

    galfenol galfenol Feb 14, 2012 5:31 PM in response to Linc Davis
    Level 1 (0 points)
    Feb 14, 2012 5:31 PM in response to Linc Davis

    Thank you everyone who contributed to debugging this issue. I am now getting used to TextWrangler, which has some nice features, like running scripts from within the editor.  All the best.

  • by etresoft,

    etresoft etresoft Feb 14, 2012 7:51 PM in response to galfenol
    Level 7 (29,178 points)
    Mac OS X
    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.

  • by galfenol,

    galfenol galfenol Feb 15, 2012 5:09 AM in response to etresoft
    Level 1 (0 points)
    Feb 15, 2012 5:09 AM in response to etresoft

    On both machines running 10.7.3 where I have this (TextEdit) problem, my accounts are in the Admin group.

  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Feb 15, 2012 5:13 AM in response to galfenol
    Level 7 (25,782 points)
    Feb 15, 2012 5:13 AM in response to galfenol

    Same here, when I reproduced this yesterday it was in an admin account also. Definitely a bug in TextEdit.

     

    Not a total loss I think you'll like TextWangler. It has some nice features.

     

    regards.

  • by etresoft,

    etresoft etresoft Feb 15, 2012 5:54 AM in response to Frank Caggiano
    Level 7 (29,178 points)
    Mac OS X
    Feb 15, 2012 5:54 AM in response to Frank Caggiano

    It is not a bug in TextEdit. I can create scripts using TextEdit and execute them. The files still have the quarantine flag. Whatever it is, is something else.

  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Feb 15, 2012 6:46 AM in response to etresoft
    Level 7 (25,782 points)
    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?

  • by etresoft,

    etresoft etresoft Feb 15, 2012 9:41 AM in response to Frank Caggiano
    Level 7 (29,178 points)
    Mac OS X
    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.

  • by etresoft,

    etresoft etresoft Feb 15, 2012 9:43 AM in response to galfenol
    Level 7 (29,178 points)
    Mac OS X
    Feb 15, 2012 9:43 AM in response to galfenol

    It might be a good idea to learn your way around vi. That is what I normally use for command-line editing. I only use TextWrangler if I am really heavy into something and/or need its particular talents.

  • by jim505,

    jim505 jim505 Feb 21, 2012 3:12 PM in response to galfenol
    Level 1 (0 points)
    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.

  • by BobHarris,

    BobHarris BobHarris Feb 21, 2012 7:01 PM in response to jim505
    Level 6 (19,405 points)
    Mac OS X
    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

first Previous Page 3 of 5 last Next