|
|
[applescript]Description
Version 1.0b2 2003-11-06 by Johan Sölve johan@montania.se Adjusted for LP7 syntax 2004-05-25 Requires PassThru 3.0 or later. http://www.execuchoice.net/ This tag executes AppleScript from within Lasso, using PassThru and osascript command line utility. The AppleScript can either be specified as text source directly when calling the tag or point to a compiled AppleScript file using the optional -file parameter. If -file is used, the tag begins looking for the script file in the specified user´s home directory but a full path from root can also be specified. Usage: applescript: '-- this is a script', -username= applescript: -file='compiled.scr', -username= Parameters: one unnamed parameter (optional) -- the script source text (can be multiple lines) -username='user' (required) -- a MacOS X username that the AppleScript is executed as. The machine must be logged in as this user (in Panther it can be one of multiple logged in users). Possibly this is not required for some type of scripts, in particular if they don´t interact with the GUI. -password='pwd' (required) -- the password of the MacOSX user that the script runs as -file='filename' (optional) -- specifies a plain text or compiled AppleScript file. Using a relative path begins looking at the user´s home directory. No Lasso file permissions are applied on the file specification. Only MacOS permissions apply. -noerr (optional) -- supress error messages from the script For more information about how AppleScripts are actually executed, type "man osascript" in Terminal. One detail to note is that the only way to pass arguments to the script is to put dynamic values in the script source text. Due to how PassThru always operates using sudo, script execution is slowed down by the sudo authentication which usually takes a few seconds. However, this is MUCH faster under 10.3 than 10.2. The sudo authentication overhead seems to be completely gone, and applescript execute much faster. Specifying a compiled AppleScript file is likely the most efficient use. Otherwise the script source must be compiled before it can be executed, and this adds some overhead. This makes no perceivable difference for small scripts, but more complex scripts would likely benefit from being precompiled. But then there´s no way to pass arguments to the script. Running AppleScript from Lasso is not suitable for a public high-traffic sites. It is better intended for low-traffic solutions where it´s likely that only a few users are expected to trigger an AppleScript at the same time. 1.0b2 2003-11-06 Adjustments in documentation use "~user/" instead of "/Users/user/" to get user´s home directory 1.0b1 2003-10-23 Initial release Parametersnone Sample Usage
Source CodeClick the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
Comments
09/07/2006, Johan Sölve
os_process On the TODO list is also to update this tag to use the native os_process tag in Lasso 8.5.
09/07/2006, Johan Sölve
Parameters in Tiger osascript starting with MacOS X 10.4 supports sending dynamic parameters to the script. The tag could use an update to support this.
06/09/2006, Brian Loomis
PassThru 2.7 This works fine with PassThru 2.7 just comment out the test for the version. |
|||||||||||||||||||
Another option
See this Tip Of The Week for a different implementation that uses [os_process]: http://www.lassosoft.com/Documentation/TotW/index.lasso?9303