Reputation: 209
I have a script file inside the "Resources" folder, I am trying to run it like this
set scriptpath to (path to current application as text)
set scripty to do shell script scriptpath/Contents/Resources/moveskript & variable1 & variable2 with administrator privileges
But it tells me this:
2015-12-01 12:19:47.208 Move[16404:534222] *** -[AppDelegate mybuttonhandler:]: Can’t make "(path.app):" into type real. (error -1700)
Upvotes: 0
Views: 160
Reputation: 3722
Your problem is this part:
... do shell script scriptpath/Contents/Resources/moveskript ...
To concatenate a literal string to a variable, you need wrap the string in quotes and use &
:
do shell script scriptpath & "/Contents/Resources/moveskript"
Because the slashes aren't within quotes, Applescript recognizes them as a division symbol, so it thinks you are trying to divide scriptpath
by Contents
. That is why it is trying to coerce the scriptpath
variable into type real
. But, since it's a string with letters, Applescript is unable to convert it.
Upvotes: 0
Reputation: 285082
Two issues:
current application
is the current AppleScript runner, not the current script / application.Use Cocoa methods to get the path to the resources folder.
set resourceFolder to current application's NSBundle's mainBundle's resourcePath()
set scriptpath to (resourceFolder's stringByAppendingPathComponent:"moveskript") as text
set scripty to do shell script quoted form of scriptpath & space & quoted form of variable1 & space & quoted form of variable2 with administrator privileges
Consider that shell parameters must be separated by space characters (between scriptpath
and variable1
and between variable1
and variable2
) and space characters within parameters must be escaped.
Upvotes: 1