Automator Shell Script Permissions Help

Discussion in 'Mac Programming' started by l8rom, Sep 14, 2014.

  1. l8rom macrumors newbie

    Sep 14, 2014
    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:
    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?
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    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:
    rm -Rf ~/Desktop/Test1/ ~/Desktop/Test2.txt /Library/Application Support/Test/
    The lack of quoting should be apparent.
  3. Intell macrumors P6


    Jan 24, 2010
    Use this:

    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:

    do shell script "rm -Rf ~/Desktop/Test1/ ~/Desktop/Test2.txt /Library/Application\\ Support/Test/"
  4. l8rom thread starter macrumors newbie

    Sep 14, 2014
    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!

Share This Page