Tech Buddy
Tech Buddy

Reputation: 9

AppleScript to copy a file present in a Restricited Folder to some other location

I want to copy the files present in a Restricted("No Access") Folder on Mac OS to some other location.

To be precise, on the folder /var/spool/cups (cups is a restricted folder) and i want to copy all the files present inside this folder to some location.

I am able to do this on terminal using sudo sh and the copying the files present in the folder, but i want to do this using an applescript.

Can you please help me with this.

Upvotes: 0

Views: 608

Answers (1)

chesh
chesh

Reputation: 750

You could try to use a Shellscript inside your Applescript with the administrator privileges attribute :

do shell script "cp /var/spool/cups/* some/other/location/" with administrator privileges

That way, you will need to enter your username and password from the terminal.

Otherwise, you could use directly the username and password for the superuser inside your Applescript :

do shell script "cp /var/spool/cups/* some/other/location/"
   user name "root"
   password "password"
   with administrator privileges

Here's official documentation on how it's done : https://developer.apple.com/library/mac/technotes/tn2065/_index.html

Upvotes: 3

Related Questions