Slashdot Mirror


AppleScript for System Admins WebCast

Justin Elliott writes "Watch Apple Computer's own AppleScript wizard, Sal Soghoian, present 'AppleScript For System Admins' during Mac OS X Labs' September 24 webcast. Learn about essential AppleScript tools and tips under Mac OS X. Discover how AppleScript can be used for administrative tasks, and how to use AppleScript to effectively interact with the Mac OS X file system."

3 of 23 comments (clear)

  1. It rocks by Anonymous Coward · · Score: 1, Interesting

    AppleScript rocks. It's a great way for users (that's users, not geeks) to automate stuff on a Mac. Its biggest power is probably the english-like language.
    Like this iChat AV example:

    tell application "iChat"
    send video invitation to account "John Doe"
    end tell

  2. I like AppleScript, but... by supton · · Score: 3, Interesting

    I wonder sometimes what Apple doesn't gradually dump AppleScript for Python? Think about it: it would give them a scripting platform as powerful as powerful as Java, but (nearly) as simple as AppleScript (perhaps more readable, and certainly more maintainable). Python 2.3 is going to get bundled with Panther, and is used in some core "essential functionality" in Panther and already has bindings to pretty much everything one would needs to tightly stitch to Apple's platform (ojbc, quartz, Java apps via JPE, etc).

    1. Re:I like AppleScript, but... by SandSpider · · Score: 2, Interesting
      You don't really need to replace AppleScript with python, per se. The ability to call Apple Events is within the ability of many scripting languages on the Mac. You can also call AppleScripts from anything that can run a program via the command line, and you can send out command line tasks through Applescripts. It's a pretty useful technique to mix Applescripts with shell scripts based on their relative strength. And, yes, Applescript has the ability to do things easily in its language that other languages can't do as easily, and those things were designed to work well with the sort of tasks that mac scripters would need.

      The main problem is that the dictionaries for the various applications's Apple Events are geared towards Applescript (if, indeed, they are geared towards anything at all. Most dictionaries thoroughly suck). If you want to make the calls from another language, you kind of have to figure out how the event calls work, but that's not a significantly more difficult task than in AppleScript, for reasons labelled above.

      The trickiest thing to do in Python instead of AppleScript would be making a Cocoa Application with it. AppleScript has AppleScript Studio, which will let you make a full, ableit slow, Cocoa Application, with logic being done in Applescript. You can include and call Objective C and Java Methods from these scripts, so if you wanted to use existing code and/or optimize some often run code, you could do that without too much trouble. It also gives you access to the entire OS framework within AppleScript, so you could make Rendezvous aware services without having to know much about Objective-C. I suspect you could use Python or Perl this way, but it might be some work getting it set up.

      From a practical perspective, I like to use whatever is handiest at the time. So, for example, if you needed to get a list of files from a web site, you could easily do
      set theString to do shell script "curl -l -s ftp://username:password@someftp.com/ | grep 'unique identifier string'"
      That could just as easily have been a one-line perl script or even a call to a script. The trickiest about passing generic scripts as a text block is making sure the text is quoted properly, but I'll leave that as an exercise to the reader.

      As far as going the other way around, and calling apple events from a shell script, I forget how to do this. There are libraries for Perl and Python that will let you do it, and you just use those functions or methods to call the Apple Events and pass the proper parameters. Here's an example for MacPerl. In any case, Google is a good tool for finding that sort of information.

      =Brian
      --
      There is nothing so good that someone, somewhere, will not hate it.