Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

operation not permitted on some shell scripts spontaneously

I have some shell scripts that I have used for years to launch Java programs, and they were working perfectly yesterday. A colleague had a shell script that needed some corrections to it, and after editing that shell script it would not run with the error "operation not permitted". After verifying that everything in the shell script worked by pasting commands into my shell, the error persisted. Then I copied the working shell script contents into the script that was not working. Still did not work. Then made a new shell script with "/bin/ls" as the contents. Did not work with same error. Then my original shell script(s) in that folder stopped working with the same "operation not permitted" error.

I discovered I can run the command "/bin/csh myscript" and that works just fine. After more frustrating attempts to find solutions I created a new shell script in my home directory with the simple one line command and it works exactly as expected. If I copy that shell script into the directory where I was working previously it stops working. And now no matter where I copy that script it won't work any longer.

There seems to be some internal security mechanism that has suddenly blacklisted shell scripts in certain directories and with certain names, but I have no idea how find where that source is, how to de-blacklist the directory or shell scripts.

Note, I have rebooted multiple times, added bash, csh, tcsh, sh and zsh to the list of programs with Full Disk Access, and even included one or two the sample shell scripts in the list of programs with Full Disk Access, and turned off Norton Internet Security. And nothing changes the result.

Posted on Feb 12, 2020 10:36 AM

Reply
Question marked as Best reply

Posted on Feb 24, 2020 1:13 PM

Check the scripts for quarantine bits. If you use Mac App Store apps to create or edit shell scripts, it will assign quarantine bits to the files. I think older versions of macOS wouldn’t block such files from running from the command line, but Catalina might.

Similar questions

5 replies

Feb 14, 2020 2:38 PM in response to sdanmcq

What OS are you using? Catalina? Catalina has added a lot more security features to restrict apps and even access to certain folders. I'm not clear on all the details myself.


Have you used the full path to your scripts when you tried to run them?


What shell are you using and what shell do you list within the scripts?


If so, then try giving the Terminal app Full Disk Access.


If this doesn't help, which folder contains your scripts?


Have you tried creating a new user account to see if the scripts work there? Or tried it from Safe Mode?



FYI, unless Norton is required by your school or employer I would suggest uninstalling it since these types of apps usually cause more problems than they solve and they can interfere with apps and cause system performance issues.

Feb 15, 2020 6:54 AM in response to HWTech

I am using Catalina. Since my original post I worked around the problem by recreating my working folder. I was careful to not copy any of the shell scripts from the original working folder. The new working folder is in the same location as the folder that had developed the restriction as described earlier, and the scripts work as expected. This working folder is a few levels deep inside my Documents folder.


I tried running the script from outside the working folder with a relative path, but never specified the full path. I didn't try as an alternate user nor in Safe Mode, mainly because I could run scripts in other places like my home directory.


I gave the Terminal app full disk access, as well as the shell programs and even the script itself. I tried with csh, zsh, sh, bash, and tcsh, and all resulted in the same "operation not permitted" error. The script would run if it was executed by passing the name as an argument to a shell program (e.g. /bin/csh myscript).


This really seems like some security mechanism that kicked in to prevent the shell script from running. I could run all of the commands from the shell script themselves, it just would not let me run any shell script in that folder or that came from that folder. And this all happened spontaneously as I had been running these very scripts minutes prior to the issue starting.

operation not permitted on some shell scripts spontaneously

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.