Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Pass arguments and run GUI AppleScripts via cron' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Pass arguments and run GUI AppleScripts via cron
Authored by: Yuckandmuck on Sep 20, '05 11:19:59AM
A followup to this hint turned me on to using UNIX environment variables to pass arguments to applescripts. Basically, I have a wrapper shell script that does little more than take the argument I passed in on the command line (or via cron), export it as a UNIX environment variable, and then call the applescript, which reads that environment variable.

Something like this:

myscript.sh:


#!/bin/sh
myarg="$1"
export myarg
osascript myscript.scpt

myscript.scpt:


set myarg to system attribute "myarg"
...

You can then use myarg throughout the applescript.

Not sure if this helps with the problem you're trying to solve, but thought I'd pass it along fwiw. It's been a useful method for me and apparently isn't tied to a particular release of OS X.

[ Reply to This | # ]