Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

l8rom

macrumors newbie
Original poster
Sep 14, 2014
2
0
I am trying to make an application that consists of a shell script to remove a list of items from any computer the script is run on. It works perfectly for items in the home folder but I will need to be removing certain items from the root Library and when the application runs it does not delete those items. The "code" is extremely simple, it is an automator app set to run an AppleScript:
Code:
do shell script "rm -Rf ~/Desktop/Test1/ ~/Desktop/Test2.txt /Library/Application Support/Test/" with administrator privileges

That same command in terminal works just fine. I have tried adding sudo and it does not help.

Is this a permissions issue? How do I get around it?
 
It looks to me like a quoting issue.

You need quotes (escaped double-quotes, or single quotes) around "Application Support" or that complete pathname. The reason this is necessary is that the directory name contains a space.

And I suspect it didn't work in Terminal unless the pathname was quoted in some way. Simply consider the command-line that would result:
Code:
rm -Rf ~/Desktop/Test1/ ~/Desktop/Test2.txt /Library/Application Support/Test/
The lack of quoting should be apparent.
 
Use this:

Code:
do shell script "sudo rm -Rf ~/Desktop/Test1/ ~/Desktop/Test2.txt /Library/Application\\ Support/Test/" password "PASSWORD" with administrator privileges

Note that is does display your administrator password in plain text.

If the Test directory in the root Library has the proper permissions on it, you can use the following as instead:

Code:
do shell script "rm -Rf ~/Desktop/Test1/ ~/Desktop/Test2.txt /Library/Application\\ Support/Test/"
 
Yeah, when I ran my original command in terminal I had it formatted as "/Library/Application\ Support/Test" and it worked in terminal. Then that didn't work in automator.

The password will be different on every machine so I wouldn't be able to bake it in like that, but entering the second "\" where the space is fixed it. Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.