Jump to content

Permissions for sandboxed apps?


Recommended Posts

I started on a workflow to call PDFPenPro via applescript to run OCR on the selected files. I have an automator service that does it, but I like Alfred better.

 

The problem I'm having is that PDFPen refuses to open the file because it doesn't have permission.

 

I checked with their support people, and they said that since the script works in AppleScript Editor and Automator, it must be an Alfred problem... 

I'd recommend letting the authors know, as there aren't too many sandboxed, scriptable apps out there… yet. - Greg from Smile Software

 

Here is the code. For testing purposes the file action only accepts one file, but if I can get that to work I'll add support for multiple files.

on alfred_script(q)	
tell application "PDFpenPro 6"
	open q 
	tell document 1
		ocr
		repeat while performing ocr
			delay 1
		end repeat
		delay 1
		close with saving
	end tell
end tell
end alfred_script

 

It is currently in an NSAppleScript action, but I've tried it as a /bin/osascript too. Even using /bin/bash or /bin/python to pass the query to a standalone script (using argv) come up with the same error, so does using osascript from the terminal. 

 

Thoughts?

Edited by dansherman
Link to comment

I started on a workflow to call PDFPenPro via applescript to run OCR on the selected files. I have an automator service that does it, but I like Alfred better.

 

The problem I'm having is that PDFPen refuses to open the file because it doesn't have permission.

 

I checked with their support people, and they said that since the script works in AppleScript Editor and Automator, it must be an Alfred problem... 

 

Here is the code. For testing purposes the file action only accepts one file, but if I can get that to work I'll add support for multiple files.

on alfred_script(q)	
tell application "PDFpenPro 6"
	open q 
	tell document 1
		ocr
		repeat while performing ocr
			delay 1
		end repeat
		delay 1
		close with saving
	end tell
end tell
end alfred_script

 

It is currently in an NSAppleScript action, but I've tried it as a /bin/osascript too. Even using /bin/bash or /bin/python to pass the query to a standalone script (using argv) come up with the same error, so does using osascript from the terminal. 

 

Thoughts?

 

The code you provided does not work in AppleScript Editor. The other portions of it might (performing the ocr and such) but the error pops up when attempting to use AppleScript to tell PDFpenPro to open the specified file. I tested it multiple ways in ASE and got the same error every time. Even stripped down to nothing but..

tell application "PDFpenPro" to open "<pathtofile>"

 

That fails every time with the same permission error.

 

I did find a way to resolve the issue though. Make a separate call to open the file, THEN perform the OCR. I tried to execute a simple "do shell script" alone, but if you do that, the second script doesn't wait on the document to finish loading before it attempts to execute the ocr command. So it HAS to be left as a, tell application "PDFpenPro" to do shell script so PDFpen will wait on that, then perform the ocr. This is what I came up with...

tell application "PDFpenPro" to do shell script "open -a '/Applications/PDFpenPro.app' '<pathtofile>'"
tell application "PDFpenPro" to ocr document 1

 

Obviously you would still need your loop that waits and then saves the document. Other than that, I think it should work.

 

Hope this helps get things going.

Link to comment

The code you provided does not work in AppleScript Editor.

Right, the ASE code used `open "/users/dansherman/test.pdf"` 

 

Make a separate call to open the file

 

Very clever, I'll give that a shot!

 

Cool cool, lemme know if you need any more help

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...