rocteur

Q: Running shell script from /Applications gives operation not permitted:

I have a shell script in a sub folder in /Applications/

 

When I run the script I get:

 

sh: operation not permitted: /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h

 

OR

 

bash: /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h: /bin/ksh: bad interpreter: Operation not permitted

 

OR

zsh: operation not permitted: /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h

 

But it works if my shell is the ksh

ksh

[%m %T %d] /Applications/SecuritySpy.app/Contents/Resources/English.lproj/Scripts/scpjr.ks h $0

 

I have run xattr -d com.apple.quarantine on the directory and file but this makes no difference.

 

Any ideas ?

iMac (27-inch, Late 2012), OS X El Capitan (10.11.6)

Posted on Jul 30, 2016 5:02 AM

Close

Q: Running shell script from /Applications gives operation not permitted:

  • All replies
  • Helpful answers

  • by rccharles,

    rccharles rccharles Jul 30, 2016 9:46 AM in response to rocteur
    Level 6 (8,459 points)
    Classic Mac OS
    Jul 30, 2016 9:46 AM in response to rocteur

    Would be helpful to see the script or at least the lines around the error.

     

    Does this script work when in some other directory?

     

    Maybe the script only works in ksh.

     

    Try something like:

     

    #!/bin/ksh

     

    as the first line

  • by rocteur,

    rocteur rocteur Jul 30, 2016 2:58 PM in response to rccharles
    Level 1 (5 points)
    Mac OS X
    Jul 30, 2016 2:58 PM in response to rccharles

    No... The script runs fine from my home dir.. It does not matter what the hash bang is set to, I've even tried to make it a Perl script and running it using /usr/bin/env zsh etc.

     

    The script just does not run in /Applications unless run the korn shell first as described in the post, this is a Mac OS X thing and it isn't a com.apple.quarantine thing..

  • by Mark Jalbert,

    Mark Jalbert Mark Jalbert Jul 31, 2016 12:40 PM in response to rocteur
    Level 5 (4,649 points)
    Jul 31, 2016 12:40 PM in response to rocteur

    The error "Operation not permitted" indicates a locked file or directory that your script is trying to operate on. The error "/bin/ksh: bad interpreter:" indicates that the script has control characters within the script and on the first line, more than likely carriage returns. When you run the script in ksh it is actuality failing, the $0 on the end is creating a new instance of the ksh shell thus hiding any error messages.