问题
I'm executing the following line in an Applescript application.
set POSIX_path to "/Applications/iPhoto.app"
do shell script "sudo rm -rfv " & quoted form of POSIX_path with administrator privileges
The authentification screen pops up as it should but after authenticating the application just freezes upon executing this command. This problems only occurs in 10.9.
When I set the permissions of the folder to be delete to "everyone can read & write" it works.
Does anyone have a clue what has been changed?
EDIT: When I repeat the execution of this script by checking du -shx /Applications/iMovie.app
it manages to delete a few more files with every try.
$ open compiled-applescript.app/
$ du -shx /Applications/iMovie.app
1.4G /Applications/iMovie.app
-- force quit AppleScript --
$ open compiled-applescript.app/
$ du -shx /Applications/iMovie.app
1.3G /Applications/iMovie.app
-- force quit AppleScript --
$ open compiled-applescript.app/
$ du -shx /Applications/iMovie.app
1.0G /Applications/iMovie.app
回答1:
Its working fine on OS X 10.9 (13A603)
set POSIX_path to "/Users/paragbafna/Desktop/untitled folder"
do shell script "sudo rm -rfv " & quoted form of POSIX_path with administrator privileges

回答2:
Does anyone have a clue what has been changed?
Well yes.. Gatekeeper has changed, that may be the cause..
When I set the permissions of the folder to be delete to "everyone can read & write" it works.
Did you do this from Finder or from the command line with chmod 0777
? The latter may delete some attributes that Finder does not remove.
What setting is selected here, on your computer?

If you have a restrictive setting, try "Anywhere" to see if it solves the problem. If this is the cause you may:
- Have custom command line tools installed, (e.g. MacPorts) or something you compiled yourself (since this is happening on 3 but not all computers and obviously you are not a "generic" user).
- Your applescript is not being trusted, you can try signing it if possible, otherwise this may work:
If the user wants to run an application blocked by Gatekeeper, they have several options. Gatekeeper could, in effect, be turned off by letting it run all applications. A power user may opt to remove the quarantine attribute or use the spctl command to add a new policy in the security assessment policy subsystem. - TrendMicro - about Gatekeeper
- Last resort idea.. Check your disk permissions, re-install Xcode if you use that, maybe the signatures are corrupted.
- Write a shell script instead, I don't know if it is just about deleting a few files, then you can definitely do it in shell script, or comment to let me know what you're trying to achieve.
回答3:
After days of trying everything to sort out this problem I finally found what was causing this issue.
It's the verbose-option (-v) of the rm-command. Leaving it out makes the application work flawless again. Maybe Apple accidently introduced a buffer overflow. I will report this under the problem ID 15309626 I created at Apple's bugtracker. Maybe they'll fix it until the first 10.10 DP :D
来源:https://stackoverflow.com/questions/19547282/applescript-application-hangs-on-10-9-when-executing-a-shell-command-with-admini