PDA

View Full Version : Manual authentication in Automator


clcrhiggaeeermo
06-12-2010, 01:17 AM
Hey all,

So I've just got a Mac, and while I'm decently good at programming, I don't know anything about AppleScript or how Macs run under the surface.

I'm about to rip my DVD library to my computer, and I'd like to do it by simply copying the entire folder structure of each disc to its own folder on the Mac. (Maybe that isn't the best way, but it leads to the question I'm asking, and I'd like to learn the answer either way)

So I'm trying to make an Automator file that simply copies the contents of a DVD into my Movies/DVDs folder. I have:

Ask for Finder Items
Get Folder Contents
New Folder (Where: my DVDs folder; Show this action when the workflow runs)

When I run this and choose my DVD in Finder when prompted, it starts to copy the files, and then I get

New Folder failed - 1 error
The operation couldn't be completed. Permission denied

So I go and see if I can drag the files manually, and I can, but I have to click "Authenticate" and put in my password before it'll let me.

My question is: can this authentication be Automated?

I'm running 10.6.3. Thanks in advance.

amramr_345
06-12-2010, 01:12 PM
...but I have to click "Authenticate" and put in my password before it'll let me.

My question is: can this authentication be Automated?

You might try pasting the script below into an Automator "Run Applescript" action's text area. Run the action immediately following the Authenticate window's appearing on screen:

on run {input, parameters}
tell application "SecurityAgent" to activate
tell application "System Events"
tell process "SecurityAgent" to set value of text field 2 of group 1 of window 1 to "abc123" -- replace abc123 with your password
delay 1
keystroke return
end tell
return input
end run

GUI scripting would need to be turned on. Under System Preferences > Universal Access, "Enable access for assistive devices" must be checked.

Tested using Mac OS 10.4.11 and Automator v. 1.0.5. Hope this helps.

clcrhiggaeeermo
06-12-2010, 05:34 PM
Thanks for the quick reply.

My problem remains unsolved, however, because the "Authenticate" box only even appears when I physically drag the items myself. When I try to copy them using Automator, I just get the error I detailed.

renaultssoftware
06-13-2010, 01:35 PM
AppleScript...
set chosenDisk to choose folder
set myDest to choose file name default name "DVD"

set diskPath to chosenDisk's POSIX path's quoted form
set newDest to myDest's POSIX path's quoted form

-- the actual stuff starts here
try
do shell script "cp " & diskPath & space & myDest with authentication user name "Frenchfries" password "Poutine"
on error
try
do shell script "sudo cp " & diskPath & " " & myDest with authentication user name "Frenchfries" password "Poutine"
on error
log "There was an error"
display dialog "There was an error"
end try
end try
I'm not sure using cp will do. Try using ditto and see.