1

I need to run a simple command like this:

do shell script "sudo cp -r /Users/me/file.plugin /Library/My-Plug-Ins" with administrator privileges

However I get "operation not permitted", with or withou sudo.

Error:

error "cp: /Users/me/file.plugin: unable to copy extended attributes to /Library/My-Plug-Ins/file.plugin: Operation not permitted
cp: /Users/me/file.plugin: Operation not permitted" number 1

I know the file exists and I know I can copy it with c++ code; however, I want something that will look more "seamless" and not have an issue so I'd prefer applescript or something more professional than a terminal window?

Currently on MacOs Monterey

10
  • 3
    In what context are you running this AppleScript? (i.e. how is this script being launched and run?) Given that it's shell script, any reason you're not just using shell script? It's likely to be a security issue with the root-level Library. Could you not move the plug-in to the user Library instead? Also, man cp doesn't list an -r flag, but an -R flag.
    – benwiggy
    Mar 20 at 7:44
  • 2
    AppleScript is considerably 'higher up' the order of things than shell scripting. It's likely that you need to give Full Disk Access to AppleEvents or Script Editor or some other process. Is this supposed to be some sort of installer?
    – benwiggy
    Mar 20 at 15:51
  • 1
    @benwiggy yes I'd like it to install a file for my application. When I export the script as an application and grant full access it still doesn't work. Similary ScriptEditor having access also doesn't work...
    – msj121
    Mar 20 at 16:33
  • 2
    Are you intending that this script should work on any computer for other users, or just for you on yours? Because there are prescribed (and proscribed!) methods for the former.
    – benwiggy
    Mar 20 at 16:35
  • 2
    The usual way is to create a .pkg file for the Installer app to run.
    – benwiggy
    Mar 20 at 17:41

1 Answer 1

1

I'm concerned this question has become an XY problem, where diagnosing errors and… "AppleScript app to home directory rights" puzzles may work and solve the problem of the moment, but would not actually then be portable, reliable, nor even advisable.

If we generalize the question to "How do I install things from an AppleScript," the best generalized answer is probably, "do not."

Please consider packing up the file into a .dmg, with an alias (aka "shortcut" or, here, a symbolic link with the absolute path) to the destination folder, so end users can install by drag-and-drop and be automatically prompted for write privileges as needed.

Or best, create a installer flat package .pkg file to install everything needed.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .