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

Previous Page 2 of 5 last Next
  • by Linc Davis,

    Linc Davis Linc Davis Feb 13, 2012 7:37 PM in response to BobHarris
    Level 10 (207,926 points)
    Applications
    Feb 13, 2012 7:37 PM in response to BobHarris

    An interpreter doesn't have to be a shell.

  • by etresoft,

    etresoft etresoft Feb 13, 2012 8:06 PM in response to galfenol
    Level 7 (29,056 points)
    Feb 13, 2012 8:06 PM in response to galfenol

    What happens when you do this?

     

    Pandora:~ jdaniel$ ls -al /bin/bash

    -r-xr-xr-x  1 root  wheel  1371648  8 Oct 01:18 /bin/bash

  • by galfenol,

    galfenol galfenol Feb 14, 2012 4:29 AM in response to Linc Davis
    Level 1 (0 points)
    Feb 14, 2012 4:29 AM in response to Linc Davis

    this ran overnight, and returned no good news or bad, in typical unix fashion.

    It did not change the behaviour of my bash scripts. Will try permissions repairs next.

  • by galfenol,

    galfenol galfenol Feb 14, 2012 4:30 AM in response to etresoft
    Level 1 (0 points)
    Feb 14, 2012 4:30 AM in response to etresoft

    ls -al /bin/bash

    -r-xr-xr-x  1 root  wheel  1371648 Jul 11  2011 /bin/bash

  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Feb 14, 2012 6:43 AM in response to galfenol
    Level 7 (25,782 points)
    Feb 14, 2012 6:43 AM in response to galfenol

    What happens of you use a diferent shell, say something like

     

    #!/bin/csh

    echo csh

  • by galfenol,

    galfenol galfenol Feb 14, 2012 8:06 AM in response to Frank Caggiano
    Level 1 (0 points)
    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

  • by Frank Caggiano,

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

  • by galfenol,

    galfenol galfenol Feb 14, 2012 9:46 AM in response to Frank Caggiano
    Level 1 (0 points)
    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.

  • by Linc Davis,

    Linc Davis Linc Davis Feb 14, 2012 9:56 AM in response to galfenol
    Level 10 (207,926 points)
    Applications
    Feb 14, 2012 9:56 AM in response to galfenol

    ...it is immediately quarantined.

     

    Boot in safe mode. Does the same thing happen?

  • by galfenol,

    galfenol galfenol Feb 14, 2012 9:57 AM in response to galfenol
    Level 1 (0 points)
    Feb 14, 2012 9:57 AM in response to galfenol

    Permission repairs had no effect.

  • by etresoft,

    etresoft etresoft Feb 14, 2012 10:08 AM in response to galfenol
    Level 7 (29,056 points)
    Feb 14, 2012 10:08 AM in response to galfenol

    Perhaps there is something wrong with your path and/or environment. Create a new account and try to write some scripts there.

  • by Frank Caggiano,

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

  • by galfenol,

    galfenol galfenol Feb 14, 2012 10:10 AM in response to Linc Davis
    Level 1 (0 points)
    Feb 14, 2012 10:10 AM in response to Linc Davis

    Booting in Safe mode has no effect on this problem.

  • by Frank Caggiano,

    Frank Caggiano Frank Caggiano Feb 14, 2012 10:16 AM in response to galfenol
    Level 7 (25,782 points)
    Feb 14, 2012 10:16 AM in response to galfenol

    Textedit is setting the quarantine bit on files it save, at least here on 10.7.3

     

    If I create a file in textedit the bit is set.

    If I edit a file created in emacs the bit is set after textedit saves it.

  • by BobHarris,

    BobHarris BobHarris Feb 14, 2012 10:19 AM in response to galfenol
    Level 6 (19,272 points)
    Mac OS X
    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

Previous Page 2 of 5 last Next