10.4: Pass command-line arguments to AppleScript

Jun 08, '05 09:13:00AM

Contributed by: adrianm

Tiger only hintI just discovered this, by looking at the man page for osascript.

From 10.4, you can now pass parameters to scripts run with oscascript. From that page:

  Any arguments following the script will be passed as a list of strings
  to the direct parameter of the ``run'' handler.  For example:

  a.scpt:
    on run argv
      return "hello, " & item 1 of argv & "."
    end run

  % osascript a.scpt world
    hello, world.
Cool!

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050523140439734